Registriert seit: 14. Jan 2003
Ort: Boxberg
456 Beiträge
Delphi 10.1 Berlin Professional
|
Re: IP Adresse ermitteln
30. Sep 2003, 11:19
Hallo,
hier eine der Möglichkeiten:
Delphi-Quellcode:
uses
WinSock;
function IPAdress:String;
const
sTxtIP = '%d.%d.%d.%d';
var
rSockVer : Word;
aWSAData : TWSAData;
szHostName : array[0..255] of Char;
pHE : PHostEnt;
begin
Result:='';
// WinSock Version 1.1 initialisieren
rSockVer:=MakeWord(1, 1);
WSAStartup(rSockVer, aWSAData );
try
FillChar(szHostName, SizeOf(szHostName), #0);
GetHostName(szHostName, SizeOf(szHostName));
pHE:=GetHostByName(szHostName);
if (pHE<>nil) then with pHE^ do
Result:=Format(sTxtIP,
[Byte(h_addr^[0]), Byte(h_addr^[1]),
Byte(h_addr^[2]), Byte(h_addr^[3])]);
finally
WSACleanup;
end;
end;
|
|
Zitat
|