Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading Device Manager's Property Fields in Windows 7/8

I am developing a windows application which gives the field details --> X.

Where X is -->

Right Click My Computer >

    Properties >

          Device Manager > (select any Item - Say KeyBoard) >

                   Click it > standard PS/2 KeyBoard >

                                double Click standard PS/2 KeyBoard >

                                           click the Details Tab >

Under the Property there are various fields like Display Name , Problem Code,Parent Siblings, etc , etc?

I want to get their values . Which Windows API I can use for this. I am doing this for windows 7 as well as windows 8.I hope the API will remain the same.Also i am having 64 bit machine. This has to be true for any device whose details I wanted to know from the Device Manager.

ALso I just want to all operations - Reading and No Set (writing) so I think I will not be having any problem with violating the Admin Rights.PLease suggest.! I have added Snapshots for reference!Say for example I want to know the current State of the HID USB Complaint Mouse(D0(Active) or D2(Sleep)).

Image Showing the Powerdata Field for HID Compliant Mouse

Image Showing the Power State for HID Complaint Mouse That is D0 - Active

I need to Get this Power State D0.

like image 619
Raulp Avatar asked Feb 21 '13 10:02

Raulp


1 Answers

The question is tagged with C#, though the actual question asks for any Window API. With the Win32 API the information can be retrieved with SetupDiGetDeviceRegistryProperty(). The steps would be:

  1. Get a device info set for the devices you're interested in via SetupDiGetClassDevs().
  2. Iterate through the device infos via SetupDiEnumDeviceInfo().
  3. Get the properties via calls to SetupDiGetDeviceRegistryProperty().
  4. Destroy the device info set via SetupDiDestroyDeviceInfoList().

According to the documentation the API is available on Windows 2000 and later.

like image 193
user686249 Avatar answered Sep 22 '22 12:09

user686249