function GetHostIP: string; {******************************************************* 描述:取得本机的IP地址函数 *******************************************************} var ch: array[1..32] of Char; i: Integer; WSData: TWSAData; MyHost: PHostEnt; IP: string; begin IP :=''; if WSAstartup(2, wsdata) <>0then Result :='0.0.0.0'; try if getHostName(@ch[1], 32) <>0then Result :='0.0.0.0'; except Result :='0.0.0.0'; end; MyHost := GetHostByName(@ch[1]); if MyHost <>nilthen begin for i :=1to4do begin IP := IP + inttostr(Ord(MyHost.h_addr^[i -1])); if i <4then IP := IP +'.' end; end; Result := IP; end;