Windows with Delphi Windows API (94) Windows Filesystem (41) Windows Forms (69) Windows Graphics (38)
Exchange Links About this site Links to us 
|
Detect your own IP Address
6 comments. Current rating: (1 votes). Leave comments and/ or rate it.
Note:
If you run through NAT then your public address can only be told by someone else like:
http://www.myip.dk/
 | |  | | uses
WinSock;
function My_IP_Address : longint;
var
buf : array [0..255] of char;
RemoteHost : PHostEnt;
begin
Winsock.GetHostName(@buf, 255);
RemoteHost:=Winsock.GetHostByName(buf);
if RemoteHost=NIL then
My_IP_Address := winsock.htonl($07000001)
else
My_IP_Address := longint(pointer(RemoteHost^.h_addr_list^)^);
Result := Winsock.ntohl(Result);
end; | |  | |  | You don't like the formatting? Check out SourceCoder then!
Comments:
|
anonymous from United States
|
|
|
|
hi
|
|
anonymous from United Kingdom
|
|
|
|
hi
|
|
anonymous from Brazil
|
 |
|
|
Well done!!!
|
2007-01-11, 15:23:22 (updated: 2007-01-11, 15:29:45) |
anonymous from Thailand
|
|
|
|
it always returns 127.0.0.1
|
|
anonymous from Singapore, Singapore
|
|
|
|
great
|
|
anonymous from United States
|
|
|
|
test
|
|