Board index » delphi » IP Address of network card/dial up adapter

IP Address of network card/dial up adapter

Hey all,

Does anyone know how to find out the IP address of the first network card
installed on a computer (except for any dial up adapters) and the IP address
of the first dial up adapter installed on a computer. programmatically.

Thanks in advance,

Nick.

 

Re:IP Address of network card/dial up adapter


Don't forget to add "WinSock" to your uses clause.

function 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(pptr^[I]^));
  Inc(I);
 end;
 WSACleanup;
end;

DC

Re:IP Address of network card/dial up adapter


But I need one procedure that will always return the IP of the network card,
and one that will always return the IP of the dial up adapter. Thanks
anyway!

Quote
"DeschutesCore" <jmcclain@nospam_magnumstudios.com> wrote in message

news:rDdV7.51351$0t.8789592@typhoon.southeast.rr.com...
Quote
> Don't forget to add "WinSock" to your uses clause.

> function 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(pptr^[I]^));
>   Inc(I);
>  end;
>  WSACleanup;
> end;

> DC

Re:IP Address of network card/dial up adapter


Quote
"Nicholas Sherlock" <n_sherl...@hotmail.com> wrote in message

news:a03qro$220$1@lust.ihug.co.nz...

Quote
> But I need one procedure that will always return the IP of the network
card,
> and one that will always return the IP of the dial up adapter. Thanks
> anyway!

How would you know then what Network card is used for cable or dsl ?

Other Threads