As @ironfroggy said, this is not specific to Python, but a general Windows question.
When we wanted to programmatically find the speed and duplex settings on network cards, it was very difficult. In the end we resorted to wandering through the registry, which has a different structure depending on the vendor of your NIC.
It goes something like this; apologies for any errors:
- Find
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network
and look for GUIDs that have the data "Network Adapters". Call this <GUID1>
.
- Underneath the
<GUID1>
key is another GUID for each NIC. Call one of them <GUID2>
.
- Go to
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\<GUID1>
.
- Iterate through its keys (they look like 0000, 0001, 0002, etc.) until you find one that has the value
NetCfgInstanceId
equal to <GUID2>
.
- Underneath here, look for a subkey dependent on NIC vendor. Some we have defined are:
- Ndi\Params
- Ndi\savedParams
- BRCMndi\params
- Under there, iterate through the keys until you find one with a value called
ParamDesc
whose data contains the words "speed" and "duplex". Remember the key name and called it <SpeedDuplexParamName>
.
- Underneath
<SpeedDuplexParamName>
there is an enum
key, which matches numbers to descriptions like "Auto-detect" and "100 Mb Full".
- Go back up a few levels to where you found
NetCfgInstanceId
. Near there you can see the current value as an enumeration. For one example here the value name was RequestedMediaType
and the value was 6.
- Look up the enumeration value to find the speed and duplex setting.
I see @DrFalk3n has linked to a Microsoft article that might say the same, but I'll leave this here in case it is helpful.