If you need to programmatically get info about the
NIC, you can find it in the registry:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}
You can enumerate through all of the sub-keys; they're labeled as 0000, 0001, 0002, etc. If you're on Windows Vista / Server 2008, be sure to catch exceptions because there is a sub-key called Properties that you will get an access violation on.
For example, in my Shuttle SG33G5, I have my primary
NIC under a sub-key called 0004. I can tell it's my primary
NIC because of the DriverDesc value. From this key, you can set duplex, buffer sizes, and other
NIC driver settings.
Just as an example, lets say you want to set your
NIC to be 100Mbps full duplex. Before you make an automated solution, you can see the values passed to the NIC driver in the sub-key called NDI under the sub-key Params. In my case, I would need to open this key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0004\Ndi\Params\*SpeedDuplex
There is a value here called
default and it's set to 0. Looking at the sub-key called enum, there are some values I could use:
0 = Auto Negotiation
1 = 10 Mbps Half Duplex
2 = 10 Mbps Full Duplex
3 = 100 Mbps Half Duplex
4 = 100 Mbps Full Duplex
So when it's time for automating this, my code would:
1) Open this key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}
2) Go through each sub-key (0000,0001,0002...), until it finds a value DriverDesc called
"Generic Marvell Yukon Chipset based Ethernet Controller".
3) I know for this card, the value 4 is 100Mbps. So I can set the value data for
"*SpeedDuplex" to 4. The full path to this registry value is
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0004\*SpeedDuplex
4) After making the change you can restart your network interface by making a shell execute call to netsh.exe
netsh interface set interface "Local Area Connection" DISABLED
netsh interface set interface "Local Area Connection" ENABLED
This article is basically documentation of some code my friend Daymion wrote. You can probably achieve the same result with WMI, but it's a lot nastier to do that in C or C++.