procedure TfrmMain.Button1Click(Sender: TObject);
var
wVersionRequested : WORD;
wsaData : TWSAData;
p : PHostEnt;
s : array[0..128] of char;
p2 : pchar;
OutPut:array[0..100] of char;
begin
{Start up WinSock}
wVersionRequested := MAKEWORD(1, 1);
WSAStartup(wVersionRequested, wsaData);
{Get the computer name}
GetHostName(@s, 128);
p := GetHostByName(@s);
{Get the IpAddress}
p2 := iNet_ntoa(PInAddr(p^.h_addr_list^)^);
StrPCopy(OutPut,'Hostname: '+Format('%s', [p^.h_Name])+#10#13+
'IPaddress: '+Format('%s',[p2])
);
WSACleanup;
MessageBox(0,OutPut,'NetInfo',mb_ok or mb_iconinformation);
end;
拷贝来的,还有IP,试试看。