Local Area Connections - renaming and mapping to physical adapters

G

Guest

I have a device that has three ethernet adapters.

My problem:
I have to some how correlate the Windows network adapter names (as seen in
device manager) to the physical hardware. Then match the network connection
names (as seen in local area connections) to the labels on the outside of the
box. Unfortunately the order in which the adapters are detected is some what
random thanks to PnP.

what I know:
How to rename a network connection using netsh command.
How to find the adapter by comparing it to the known pci slot number using
api calls.

What I need:
How can I find out (programmatically) at FBA what local area connection
belongs to what physical adapter?

Thanks
 
G

Guest

Thanks for the help,

What I decided to do was use the setupapi to enumerate the physical adapters
and get their pnp instance id, pci bus & device number.

I then enumerated the NET device class in the registry looking for network
connections that share the same PnpInstanceID.

I was then able to match up the network connections to the hardware devices
and with the knowledge of the PCI bus and device number generate a batch file
that used netsh to rename and set the ip addresses of the network connections.

What I really don't understand is why there aren't any clearly documented
api's for:

Enumerating the network connections (just like the "Network Connections"
control panel applet).
Relating the network connections to the hardware.
Changing the ip addresses that are persistent beyond a reboot.

I've done some extensive Google searches and everyone just churns through
the registry. There just has to be a better way :)

Thanks again for taking the time to help.
 
S

Slobodan Brcin \(eMVP\)

Hi Silent,

Have you loked at INetConnectionManager ?
You will be able to enumerate for INetConnection interfaces, and then you will have access to NETCON_PROPERTIES structure it this
what you are looking for?
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ics/ics/netcon_properties.asp
Changing the ip addresses that are persistent beyond a reboot.
"netsh interface ip" can do this, so can we. I have created program that set ip address without touching registy, but you can
torture me now and I won't be able to remember how to do this.
Search trough all NG on the net I think that there is source out there.

BTW:
Network interfaces are very tricky snce there are many interfaces that look alike, some old, some new and all implemented on
different levels and in different services and drivers, so this is mildly said a chaos, and in this chaos you need to find the
things that are most apropriate for you to use.

Regards,
Slobodan
 
K

KM

SilentCode,

Why didn't you like the IP Helper Functions?
To enumerate network connections you could use GetNumberOfInterfaces/GetAdaptersInfo/GetInterfaceInfo.

And as Slobodan mentioned, take a look at relatively new interfaces for ICS and ICF like IEnumNetSharingEveryConnection:
http://msdn.microsoft.com/library/en-us/ics/ics/ienumnetsharingeveryconnection.asp
Have you loked at INetConnectionManager ?
You will be able to enumerate for INetConnection interfaces, and then you will have access to NETCON_PROPERTIES structure it this
what you are looking for?
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ics/ics/netcon_properties.asp

"netsh interface ip" can do this, so can we. I have created program that set ip address without touching registy, but you can
torture me now and I won't be able to remember how to do this.

I did that though the registry and it worked very stable. Beside "Windows version" problem I don't see much issues with such
approach.
Search trough all NG on the net I think that there is source out there.

BTW:
Network interfaces are very tricky snce there are many interfaces that look alike, some old, some new and all implemented on
different levels and in different services and drivers, so this is mildly said a chaos, and in this chaos you need to find the
things that are most apropriate for you to use.

And even worse - the reg key and structure is changing from Window version to version :-(
On NT/2K/XP there were some changes and we always struggle to port our code (to find out those undocumented changes).

Konstantin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top