![]() |
#2
anthony6342009-08-12 18:43
unit Unit1;
interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,winsock, StdCtrls; type TForm1 = class(TForm) Button1: TButton; ListBox1: TListBox; Label1: TLabel; Label2: TLabel; Edit1: TEdit; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.Button1Click(Sender: TObject); type TAddrList = array [0..20] of PInAddr; PAddrList = ^TAddrList; var phent : PHostEnt; P: PAddrList; I : Integer; begin phent := GetHostByName(pchar(edit1.text)); if phent<>nil then begin I := 0; P := PAddrList(phent^.h_Addr_list); while P[I] <> nil do begin listbox1.items.Add(StrPas(inet_ntoa(P[I]^))); Inc(I) end end; end; procedure TForm1.FormCreate(Sender: TObject); var WSAData : TWSAData; begin edit1.text := 'www.bccn.net'; if (WSAStartup(MAKEWORD(2,0),WSAData)<>0) then raise Exception.Create('Winsock Version Error'); end; procedure TForm1.FormDestroy(Sender: TObject); begin WSACleanUP; end; end. |
我要知道本机的IP 不用命令行,用DELPHI完成,不是局域IP,而是网络IP怎么实现???
请教高手(高分找答案)