I know how to use the Setup API to enable and disable devices. What I need to know is, can I use this same API to determine if a device is enabled/disabled? I think the real question is how to use it thusly because Microsoft’s devcon uses the Setup API for its manipulation of hardware and that program will tell you if a device is enabled or disabled (as does the Device Manager). How is this done? My research of the Setup API methods to this point doesn’t show a clear answer.
Andy
This API from MS has got to be among the least used, understood and worst documented. As I mentioned in my original post, the Setup API can be used to enable/disable hardware. So, I thought I would take a few moments and supply the community with how I finally figured out how to check the status of hardware.
So, the short answer: you don’t do this from the Setup API. Of course, this makes sense. After all, since you can change the devices state, i.e. enable or disable, using the Setup API: it naturally follows that you’d have to use a completely different API to determine the device’s current state. Now, enter the Configuration Manager 32 API. To enable/disable hardware, you have to use the Setup API, but to figure out what state the hardware is in, you have to use the ConfigMgr 32 API (#include cfgmgr32.h). Makes sense, right?
There may be other ways of doing this, but here’s what I did.
You’ll have to figure out the GUID for the hardware you’re after by searching through the list found here. Some of these, at least, are predefined in various Windows headers. However, at this point, I know of very few and have only stumbled onto them by accident.
Relevant links to the functions used above:
SetupDiDestroyDevieInfoList
CM_Get_DevNode_Status
CM_Get_Device_ID
SetupDiEnumDeviceInfo
SetupDiGetClassDevs
SP_DEVINFO_DATA
I hope this helps someone.