如何取得局域网内的计算机名?

I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
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;
 

Similar threads

顶部