Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to get PNP Device Id

How to get PNP Device Id

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++sysadminwindows-adminjson
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jaligamap
    wrote on last edited by
    #1

    I am looking a way to get PNP device Id for USB, CDRom, and hard disks, mapped network drives. I know we can get through WMI calls. My project requires not to use WMI and I am looking ways to get the PNP device id through windows native API calls. I figured out that PNP device ids are listed in windows registry "HKLM\SYSTEM\CurrentControlSet\services\{service}\Enum. Where {service} could be CDROM, disk, USBSTOR etc.... I have following questions on this. 1. How can I link back this "PNP device id" to the mounted volume letter? 2. Not finding a way to get "PNP device id" for network mapped drives? 3. Is there any IOCTL call to get the "PNP device id" for any volume or drive? Thanks in advance

    L 1 Reply Last reply
    0
    • J Jaligamap

      I am looking a way to get PNP device Id for USB, CDRom, and hard disks, mapped network drives. I know we can get through WMI calls. My project requires not to use WMI and I am looking ways to get the PNP device id through windows native API calls. I figured out that PNP device ids are listed in windows registry "HKLM\SYSTEM\CurrentControlSet\services\{service}\Enum. Where {service} could be CDROM, disk, USBSTOR etc.... I have following questions on this. 1. How can I link back this "PNP device id" to the mounted volume letter? 2. Not finding a way to get "PNP device id" for network mapped drives? 3. Is there any IOCTL call to get the "PNP device id" for any volume or drive? Thanks in advance

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Hi, Although the MSDN recommends to *not* use the PnP functions... I have always used CM_Get_DevNode_Registry_Property_Ex[^] with the CM_DRP_HARDWAREID and CM_DRP_COMPATIBLEIDS. Some pretty good PnP information here: [MS-PNPR]: Plug and Play Remote (PNPR) Protocol Specification[^] Best Wishes, -David Delaune

      P 1 Reply Last reply
      0
      • L Lost User

        Hi, Although the MSDN recommends to *not* use the PnP functions... I have always used CM_Get_DevNode_Registry_Property_Ex[^] with the CM_DRP_HARDWAREID and CM_DRP_COMPATIBLEIDS. Some pretty good PnP information here: [MS-PNPR]: Plug and Play Remote (PNPR) Protocol Specification[^] Best Wishes, -David Delaune

        P Offline
        P Offline
        pacchij
        wrote on last edited by
        #3

        Thanks david for quick answer. I was looking for PNP functions and references you pointed. Definitely these API's looks promising to find PNP device Id. However, how I can map my volume (drive letter) to its PNP device Id. neither of functions actually refer for volume drive letter. thanks- Prashanth

        L 1 Reply Last reply
        0
        • P pacchij

          Thanks david for quick answer. I was looking for PNP functions and references you pointed. Definitely these API's looks promising to find PNP device Id. However, how I can map my volume (drive letter) to its PNP device Id. neither of functions actually refer for volume drive letter. thanks- Prashanth

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Hi Prashanth, If you have a look at the following: System-Defined Device Setup Classes Available to Vendors[^] You will see that the class ID for disk drives is: {4d36e967-e325-11ce-bfc1-08002be10318} You need to call CM_Get_DevNode_Registry_Property_Ex[^] with the disk drive class ID. Have a look at the article by A. Riazi. Enumerate Properties of an Installed Device[^] You should easily be able to modify the code he provides to retrieve the device ID. Best Wishes, -David Delaune

          P 1 Reply Last reply
          0
          • L Lost User

            Hi Prashanth, If you have a look at the following: System-Defined Device Setup Classes Available to Vendors[^] You will see that the class ID for disk drives is: {4d36e967-e325-11ce-bfc1-08002be10318} You need to call CM_Get_DevNode_Registry_Property_Ex[^] with the disk drive class ID. Have a look at the article by A. Riazi. Enumerate Properties of an Installed Device[^] You should easily be able to modify the code he provides to retrieve the device ID. Best Wishes, -David Delaune

            P Offline
            P Offline
            pacchij
            wrote on last edited by
            #5

            Thanks david for quick reply. I was able to enumerate all the device ID's with the above calls. Definitely this is good progress for what I am looking. However, none of the API's are actually refering the device id to the respective volume drives. For example, if I could enumerate CDRom drives device id's, there is no way to know their volume drive letters. In other way, volume information and corresponding device info are not related with these API's. If you open "Device Manager" and select any disc drive, open properties and then volumes tab, this will not list all the volumes by default. However when you select "Populate", it is displaying all the volumes in the respective drive. This is what exactly I am looking. Either I should know volumes mounted on particular "Device ID" (or) get the device id for a given volume letter. I dont know how "device manager" is populating drives with the device id? Any thoughts or pointers? Thanks- Prashanth Jaligama

            P 1 Reply Last reply
            0
            • P pacchij

              Thanks david for quick reply. I was able to enumerate all the device ID's with the above calls. Definitely this is good progress for what I am looking. However, none of the API's are actually refering the device id to the respective volume drives. For example, if I could enumerate CDRom drives device id's, there is no way to know their volume drive letters. In other way, volume information and corresponding device info are not related with these API's. If you open "Device Manager" and select any disc drive, open properties and then volumes tab, this will not list all the volumes by default. However when you select "Populate", it is displaying all the volumes in the respective drive. This is what exactly I am looking. Either I should know volumes mounted on particular "Device ID" (or) get the device id for a given volume letter. I dont know how "device manager" is populating drives with the device id? Any thoughts or pointers? Thanks- Prashanth Jaligama

              P Offline
              P Offline
              pacchij
              wrote on last edited by
              #6

              HI David, thanks for all your pointers. I am able to successfully enumerate volumes and their corresponding Device information using SetupDI functions. 1. SetupDI functions will list all devices for given class guid, such as disks, cdroms, volumes. We can also query for its device number using IOCTL_STORAGE_GET_DEVICE_NUMBER. 2. Separately, all volumes can be retrieved using windows APIs, such as GetLogicalDrives, and then we can also query its device number using same IOCTL_STORAGE_DEVICE_NUMBER on drive letter (ex: \\\\?\\c:). Now I mapped device number in setupDI with the device number retrieved using volumes functions, which allows me to get both volume information and also its corresponding device information. Of course, device number does not persist across boots, but my little software will keep refresh to map volume drives and its corresponding device info. thanks- Prashanth Jaligama

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups