uses winsock;
{=================================================================
功 能: 返回本机的Ip地址
参 数: 无
返回值: 成功: Ip 失败: ''
备 注:
版 本: 1.0 2011/06/06 21:05:00
=================================================================}
function Fun_ComputerLocalIP: string;
var
ch: array[1..32] of char;
wsData: TWSAData;
myHost: PHostEnt;
i: integer;
begin
Result := '';
if WSAstartup(2,wsData)=0 then // start winsock
try
if GetHostName(@ch[1],32)<>0 then Exit; // getHostName failed
myHost := GetHostByName(@ch[1]); // GetHost error
if myHost<> nil then
for i:=0 to 3 do
begin
Result := Result + IntToStr(Ord(myHost.h_addr^[i]));
if i<3 then Result := Result + '.';
end;
finally
WSACleanup;
end;
end;
//说明:防止同一用户在不同的地方(IP)登录,以前用IDNY的一个属性,后来在网上搜了一下,觉得用这个较方便;