?
Solved

All netowrk interfaces list (ip and subnetmask)

Posted on 2003-11-17
5
Medium Priority
?
236 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 8

Accepted Solution

by:
gmayo earned 1200 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month14 days, 1 hour left to enroll

801 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