Board index » delphi » How can I manage to detect the real Ip address of a machine which is on the

How can I manage to detect the real Ip address of a machine which is on the

How can I manage to detect the real Ip address of a machine which is on the
internet using a lan.
I have tried many components but, each time, they gave me my network card IP
address. How to have the external IP address ?
Is there an API or a registry key I could use ? If yes, what are they ?

Thank you

 

Re:How can I manage to detect the real Ip address of a machine which is on the


This will find any computers on you LAN. Then use function "GetHostByName"
to get those computer's IP adresses

Vlado

procedure EnumNetResources(List: TStrings);

  procedure EnumFunc(NetResource: PNetResource);
  var
    Enum: THandle;
    Count, BufferSize: DWORD;
    Buffer: array[0..16384 div SizeOf(TNetResource)] of TNetResource;
    i: Integer;
  begin
    if WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_ANY, 0, NetResource,
Enum) = NO_ERROR then
    try
      Count := $FFFFFFFF;
      BufferSize := SizeOf(Buffer);
      while WNetEnumResource(Enum, Count, @Buffer, BufferSize) = NO_ERROR do
        for i := 0 to Count - 1 do
        begin
          if Buffer[i].dwDisplayType = RESOURCEDISPLAYTYPE_SERVER then
            List.Add(Buffer[i].lpRemoteName);
          if (Buffer[i].dwUsage and RESOURCEUSAGE_CONTAINER) > 0 then
            EnumFunc(@Buffer[i])
        end;
    finally
      WNetCloseEnum(Enum);
    end;
  end;

begin
  EnumFunc(nil);
end;

Quote
"Mathos" <djmat...@yahoo.fr> wrote in message

news:992738671.820908@romulus.infonie.fr...
Quote
> How can I manage to detect the real Ip address of a machine which is on
the
> internet using a lan.
> I have tried many components but, each time, they gave me my network card
IP
> address. How to have the external IP address ?
> Is there an API or a registry key I could use ? If yes, what are they ?

> Thank you

Other Threads