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. Hardware & Devices
  4. How to get the device instance id of a disk or volume?

How to get the device instance id of a disk or volume?

Scheduled Pinned Locked Moved Hardware & Devices
questiontutorial
2 Posts 2 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.
  • H Offline
    H Offline
    Hemant kulkarni
    wrote on last edited by
    #1

    I am developing a software where I store the Instance ID of every disk in the system. How can I get the Instance ID from a disk number? e.g I want Instance ID of DIsk0 DIsk1 etc.? here is what I am doing 1] SetupDiClassGuidsFromNameA("DiskDrive",***); to get the GUID for disk drives 2]SetupDiEnumDeviceInf(***) to enumrate all the disks.This gives me Instance ID's of all the disks but how can I get the device instance ID of spesific disk(like Disk0)?

    R 1 Reply Last reply
    0
    • H Hemant kulkarni

      I am developing a software where I store the Instance ID of every disk in the system. How can I get the Instance ID from a disk number? e.g I want Instance ID of DIsk0 DIsk1 etc.? here is what I am doing 1] SetupDiClassGuidsFromNameA("DiskDrive",***); to get the GUID for disk drives 2]SetupDiEnumDeviceInf(***) to enumrate all the disks.This gives me Instance ID's of all the disks but how can I get the device instance ID of spesific disk(like Disk0)?

      R Offline
      R Offline
      ruready511
      wrote on last edited by
      #2

      Your best bet is to use WMI. The following code was pulled from Microsoft's WMI Code Creator (you can download it from their website): strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_DiskDrive",,48) For Each objItem in colItems Wscript.Echo "-----------------------------------" Wscript.Echo "Win32_DiskDrive instance" Wscript.Echo "-----------------------------------" Wscript.Echo "DeviceID: " & objItem.DeviceID Next This is a .vbs script, but the WMI Code Creator will output to VB.NET and C# as well. Hope this helps...

      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