Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

All netowrk interfaces list (ip and subnetmask)

Posted on 2003-11-17
5
Medium Priority
?
237 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

618 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