- uses winsock;
- function GetIpAddress: string;
- var phoste: PHostEnt;
- Buffer: array [0..100] of char;
- WSAData: TWSADATA;
- begin
- result:='';
- if WSAStartup($0101, WSAData) <> 0 then exit;
- GetHostName(Buffer,Sizeof(Buffer));
- phoste:=GetHostByName(buffer);
- if phoste = nil then result:='127.0.0.1';
- else result:=StrPas(inet_ntoa(PInAddr(phoste^.h_addr_list^)^));
- WSACleanup;
- end;