Function GetNameByIP(MIP:string; var Name:string):boolean; var PHt:PHostEnt; WSData: TWSAData; i:Word; j:integer; k:u_long; begin result:=false; i:=MAKEWORD(1,1); if WSAStartup(i,WSData)<>0 then exit; k:=inet_addr(PChar(MIP)); PHt:=gethostbyaddr(@k,4,PF_INET); if PHt=nil then begin j:=WSAGetLastError; Name:='Error:'+inttostr(j-WSABASEERR); end else begin Name:=PHt.h_name; result:=true; end; WSACleanup; end;
Function GetNameByIP(MIP:string; var Name:string):boolean; var PHt:PHostEnt; WSData: TWSAData; i:Word; j:integer; k:u_long; begin result:=false; i:=MAKEWORD(1,1); if WSAStartup(i,WSData)<>0 then exit; k:=inet_addr(PChar(MIP)); PHt:=gethostbyaddr(@k,4,PF_INET); if PHt=nil then begin j:=WSAGetLastError; Name:='Error:'+inttostr(j-WSABASEERR); end else begin Name:=PHt.h_name; result:=true; end; WSACleanup; end;
var
PHt:PHostEnt;
WSData: TWSAData;
i:Word;
j:integer;
k:u_long;
begin
result:=false;
i:=MAKEWORD(1,1);
if WSAStartup(i,WSData)<>0 then exit;
k:=inet_addr(PChar(MIP));
PHt:=gethostbyaddr(@k,4,PF_INET);
if PHt=nil then begin
j:=WSAGetLastError;
Name:='Error:'+inttostr(j-WSABASEERR);
end else begin
Name:=PHt.h_name;
result:=true;
end;
WSACleanup;
end;
var
PHt:PHostEnt;
WSData: TWSAData;
i:Word;
j:integer;
k:u_long;
begin
result:=false;
i:=MAKEWORD(1,1);
if WSAStartup(i,WSData)<>0 then exit;
k:=inet_addr(PChar(MIP));
PHt:=gethostbyaddr(@k,4,PF_INET);
if PHt=nil then begin
j:=WSAGetLastError;
Name:='Error:'+inttostr(j-WSABASEERR);
end else begin
Name:=PHt.h_name;
result:=true;
end;
WSACleanup;
end;
如果不行,你再试一试shlobj