相关代码 |
|
通过机器名得到IP地址 function procedure TForm1.nametoip(name:string):string; var WSAData: TWSAData; HostEnt: PHostEnt; begin result:=''; WSAStartup(2, WSAData); HostEnt := gethostbyname(PChar(name)); if HostEnt nil then begin with HostEnt^ do result:= Format('%d.%d.%d.%d', [Byte(h_addr^[0]), Byte(h_addr^[1]), Byte(h_addr^[2]), Byte(h_addr^[3])]); end; WSACleanup; end;
相关资源 |
|