Solved

All netowrk interfaces list (ip and subnetmask)

Posted on 2003-11-17
5
228 Views
Last Modified: 2010-04-05
Hi.
I want to obtain a list of ALL available network interfaces on a system. I want a list of ip-subnetmask pairs, one pair for each subnet the computer is on. The computer may have more than one network cards, or the network card may have more ips assigned to it, or I may have a netorkcard and an active dial-up connection, etc. Basicaly, I want to see all the interfaces, just like you do when you run the "ifconfig" command on a Unix system. I only need the ip and subnetmask for each. I hope you got it :)

I've done some digging in the registry and I kinda found there what I am looking for, but the information there is rather inconsistent (dial-up info is in once place, network card info in another place, etc.)
I need a consistent solution for listing all netowrk interfaces that will work on all (most) windows versions (95, 98, ME, XP, 2k, etc.)

Also, it would be nice to be notifyed when any of these change (under win XP, if the user changes the ip, I want to be notifyed, or if the user connects/disconnects trough dial-up). This part is not very important cos I can always check manualy from time to time.
0
Comment
Question by:Muqker
  • 3
5 Comments
 
LVL 8

Accepted Solution

by:
gmayo earned 300 total points
ID: 9769638
There is a previous question:
http://oldlook.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20352829.html?query=list+all+network+cards&searchType=topic

I do have another solution but I need to find it first... watch this space if nobody else gets here first!

Geoff M.
0
 
LVL 8

Expert Comment

by:gmayo
ID: 9769664
procedure GetIPs(s : TStrings);
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);
      s.Clear;
      GetHostName(Buffer, SizeOf(Buffer));
      phe := GetHostByName(buffer);
      if phe <> nil then begin
            pPtr := PaPInAddr(phe^.h_addr_list);
            I := 0;
            while pPtr^[I] <> nil do
            begin
                  s.Add(inet_ntoa(pptr^[I]^));
                  Inc(I);
            end;
            WSACleanup;
      end;
end;

That will get all the IP addresses (my PC has 2: one for the ethernet card; one for the USB broadband modem). There is a much longer example on http://oldlook.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_10126142.html which gets the subnet mask as well.

Geoff M.
0
 
LVL 8

Expert Comment

by:gmayo
ID: 10086771
Any good?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ddeman not working in activex 3 93
indy Tmemory stream non latin charcter issue 2 98
JAudiorecorder record freezing the app 29 60
Delphi and Access based Enumeration 9 48
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now