Computing.Net > Forums > Programming > Generate list of network interfaces

Generate list of network interfaces

Reply to Message Icon

Original Message
Name: SmittyZ3M
Date: August 8, 2005 at 07:34:43 Pacific
Subject: Generate list of network interfaces
OS: WinXP Home
CPU/Ram: 1.6GHz / 768MB
Comment:

I am looking for a way to print a list of network interfaces on a given PC. When I say a list of network interfaces, I mean the names of the interfaces as seen via Control Panel -> Network Connections. Windows likes to give default names such as Local Area Connection, Wireless Network Connection, etc. I personally change these names to keep things straight in my head.

The application that I have already written allows a person to create "profiles" containing different IP configurations that they need to change as they visit and join diffferent LANs with different IP designs and layouts. Once their profiles are created, they simply point and click and the program makes the changes to their interface automatically. This eliminates the need to remember different IP addressing info.

My problem right now is when they are creating these profiles, they have to type the name of the network interface for a particular profile into a text field, and it has to be spelled 100% correctly or the profile will not work. I would like a way to search the computer for the names of all interfaces so I can place these in a ComboBox. I would also like to find a list of the interfaces so when they go to make a switch, the program first checks to see if that interface is even enabled before the switch occurs.

Does anyone know how to do this?


Report Offensive Message For Removal


Response Number 1
Name: Michael J (by mjdamato)
Date: August 9, 2005 at 06:30:29 Pacific
Subject: Generate list of network interfaces
Reply: (edit)

You don't say what language you are using. It would need access to the registry since that is where the information is stored. You might need to get some more detailed information about how those names are stored. On this computer the name of the network connection is stored in two different places on the computer (plus there are guids int he path that make it more difficult as well):

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\{1E6AF554-25FF-40FC-9CEE-EB899472C5A3}\Connection]
"PnpInstanceID"="PCI\\VEN_14E4&DEV_1696&SUBSYS_12BC103C&REV_03\\4&3A321F38&0&10F0"
"MediaSubType"=dword:00000001
"Name"="Lan Name"
"ShowIcon"=dword:00000000
"IpCheckingEnabled"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\{1E6AF554-25FF-40FC-9CEE-EB899472C5A3}\Connection]
"PnpInstanceID"="PCI\\VEN_14E4&DEV_1696&SUBSYS_12BC103C&REV_03\\4&3A321F38&0&10F0"
"MediaSubType"=dword:00000001
"Name"="Lan Name"
"ShowIcon"=dword:00000000
"IpCheckingEnabled"=dword:00000001

Michael J


Report Offensive Follow Up For Removal

Response Number 2
Name: FishMonger
Date: August 9, 2005 at 16:56:00 Pacific
Subject: Generate list of network interfaces
Reply: (edit)

Here's a simple Perl solution. With the Win32::IPConfig module, you can easily get any/all of the adapter info you need.


#!perl -w

use Win32::IPConfig;

$host = shift || '127.0.0.1';
$ipconfig = Win32::IPConfig->new($host);

foreach $adapter ($ipconfig->get_adapters) {
print 'Adapter: ', $adapter->get_name, "\n";
}

http://search.cpan.org/~jmacfarla/Win32-IPConfig-0.08/lib/Win32/IPConfig.pm


Report Offensive Follow Up For Removal

Response Number 3
Name: SmittyZ3M
Date: August 10, 2005 at 05:53:40 Pacific
Subject: Generate list of network interfaces
Reply: (edit)

Thanks for the replies. To follow up, the application is written in VB 6. Yesterday I did some research and wrote a VB.NET application which examimes the registry and extracts the names of the network interfaces. The locations of the names of these interfaces seems to be the same for XP and Win 2000, which are the operating systems that I designed this application for.

FishMonger:

I have little experience with perl, but I tried to run your program. When I try to run it from my PC, I get:

C:\>perl test.pl
Can't locate Win32/IPConfig.pm in @INC (@INC contains: C:/Perl/lib C:/Perl/site/
lib .) at test.pl line 3.
BEGIN failed--compilation aborted at test.pl line 3.

Is this a PATH issue? Also, does this script extract the "real" name of the interface or the "Windows" name of the interface? For example, the "real" name of an interface might be Broadcom 802.11g Packet Scheduler...... but the "Windows" name for that as seen in Network Connections is most likely "Wireless Network Connection" or whatever you wish to name it. My program needed the "Windows" name which I was able to extract from the registry. I also wrote a Java application to extract these names using the NetworkInterface class in the java.net package, but it grabbed the real interface names.

Thanks again.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Generate list of network interfaces

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge