How do you find the disk ID of a drive

jvcoach23

Member
Joined
Feb 21, 2005
Messages
17
Location
IL
Programming Experience
1-3
i'm trying to list out the what to pick when using the perfmon counter, physical disk. when you look at it in perfmon, it shows for example, 0 C:, 1 D:. I see how to get the drive letters avaliable on the sytem.. but i can't figure out how in vb.net to get the disk id. Can someone help me out.. i want to get a listing of all the hard drives on the system, both their ID and the drive letter.

anyway, hopefully someone can help out
Thank
Shannon
 
close.. but not quite

i also need the drive number associated with the drive... like when you look at perfmon... and go into a physical drive and go down to the instance level.. you'll see it list the drive as 0 C:, 1 D: something like that.. that is what i also need...

have any ideas?
thanks
shannon
 
Got it.. thanks for the reply.. put me on the right track.

Here is the code

Dim scope As ManagementScope
scope = New ManagementScope( _
"\\computername\root\cimv2")
scope.Connect()
Dim query As ObjectQuery
query = New ObjectQuery( _
"SELECT * FROM Win32_PerfRawData_PerfDisk_PhysicalDisk")
Dim objOS As ManagementObjectSearcher
objOS = New ManagementObjectSearcher(scope, query)



Dim objMgmt As ManagementObject
Dim aryHardDiskOnSystem As New ArrayList

For Each objMgmt In objOS.Get
aryHardDiskOnSystem.Add(objMgmt("name").ToString())
Next
 
I'm glad you got it worked out and even more glad you came back and posted your solution.

Hopefully it will help someone else with the same, or similiar, question. :)
 
Back
Top