xxxxx@gmail.com wrote:
I’ve been trying to use the python ctypes library (which talks to Windows DLLs directly) to make calls to SetupAPI and get a network adapter’s CompatibleIDs
There’s a built-in Python module to convert a GUID string to binary:
import uuid
x = uuid.UUID(‘{00010203-0405-0607-0809-0a0b0c0d0e0f}’)
print x.bytes
- (For now manually) get the GUID of my device from the reg key HKLM\Software\Microsoft\Windows NT\CurrentVersion\NetworkCard<networkconnection status>
>
Where did you get this code? You fetch the NetConnectionStatus, and
look that up in the NetworkCards registry key. That’s just garbage –
there’s no relationship between those two values. My network adapter
returns a NetConnectionStatus of 2 (“connected”), but there’s no subkey
“2” under NetworkCard. The only two things under NetworkCard on my
machine are the two 1394 network adapters (11 and 17).
> 2) Is there a simpler or more practical approach for distinguishing between a LAN and Wireless adapter? Win32_NetworkAdapter.AdapterTypeId is not consistent on the wireless cards that I’ll be querying.
>
In that case, I think your task is hopeless. The card or driver is
lying to Windows, and everything else is going to lie to you as well.
> 2) Call SetupDiGetClassGetDevsW with a GUID object and get back a Device Information Set
> 3) Call SetupDiEnumDeviceInterfaces with the returned handle from one, and a pointer to a SP_DEVICE_INTERFACE_DATA object.
>
> Now, the return value from 2 comes out False, and when I call GetLastError it gives me a 259 (For No More Items I believe)
>
> Questions:
> 1) Can anyone suggest why it can’t find my network card even though I give it the correct GUID?
>
Because the GUID that you’re fetching is not a Device Interface GUID.
It’s just the name of the registry Services key for that device. Where
did you get the idea that this would work?
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.