bryan7
asked on
what's my INTERNET IP ?
this only works when my pc is not in a LAN network..
if I'm on LAN this code gets the LAN IP not the internet IP..
how do I retrieve it ?
function TFunctions.LocalIP : string;
type TaPInAddr = array [0..10] of PInAddr;
PaPInAddr = ^TaPInAddr;
var
phe : PHostEnt;
pptr : PaPInAddr;
Buffer : array [0..63] of char;
I : Integer;
GInitData : TWSADATA;
begin
WSAStartup($101, GInitData);
Result := '';
GetHostName(Buffer, SizeOf(Buffer));
phe :=GetHostByName(buffer);
if phe = nil then Exit;
pptr := PaPInAddr(Phe^.h_addr_list );
I := 0;
while pptr^[I] <> nil do begin
result:=StrPas(inet_ntoa(p ptr^[I]^)) ;
Inc(I);
end;
WSACleanup;
end;
if I'm on LAN this code gets the LAN IP not the internet IP..
how do I retrieve it ?
function TFunctions.LocalIP : string;
type TaPInAddr = array [0..10] of PInAddr;
PaPInAddr = ^TaPInAddr;
var
phe : PHostEnt;
pptr : PaPInAddr;
Buffer : array [0..63] of char;
I : Integer;
GInitData : TWSADATA;
begin
WSAStartup($101, GInitData);
Result := '';
GetHostName(Buffer, SizeOf(Buffer));
phe :=GetHostByName(buffer);
if phe = nil then Exit;
pptr := PaPInAddr(Phe^.h_addr_list
I := 0;
while pptr^[I] <> nil do begin
result:=StrPas(inet_ntoa(p
Inc(I);
end;
WSACleanup;
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Cool.. tested on NT Server 4 SP 6 and it works! (D5 SP1 Ent)
Alex
Alex
ASKER
Hi f15iaf, sorry I haven't accepted it yet, I couldn't test it until now..
it was autograded with B, so I'll give you some more points.. look in the new questions section
thanks.
it was autograded with B, so I'll give you some more points.. look in the new questions section
thanks.
ASKER