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