I am trying to get the "real" hd serial and it's path:
' query the Win32_DiskDrive class first
Dim searcher As New ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")
For Each wmi_HD As ManagementObject In searcher.Get()
Dim hd As New HDClass
hd.Model = wmi_HD("Model").ToString()
hd.Type = wmi_HD("InterfaceType").ToString()
hd.PhysicalDrive = wmi_HD("DeviceID").ToString()
hd.MediaType = wmi_HD("MediaType").ToString()
hd.Name = wmi_HD("Name").ToString()
hd.SystemName = wmi_HD("SystemName").ToString()
hd.Caption = wmi_HD("Caption").ToString()
hdCollection.Add(hd)
Next
' extract the serial number from Win32_PhysicalMedia class
Dim searcher2 As New ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia")
Dim i As Integer = 0
For Each wmi_HD As ManagementObject In searcher2.Get()
' get the hard drive from collection
' using index
Dim hd As HDClass = DirectCast(hdCollection(i), HDClass)
' get the hardware serial no.
If wmi_HD("SerialNumber") Is Nothing Then
hd.Serial = "None"
Else
hd.Serial = wmi_HD("SerialNumber").ToString()
End If
i += 1
Next
The problem is that I can't get the logical path like "c:", just the physicalpath: \\.\PHYSICALDRIVE0
How can I get the logical drive letter from the physical path?
' query the Win32_DiskDrive class first
Dim searcher As New ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")
For Each wmi_HD As ManagementObject In searcher.Get()
Dim hd As New HDClass
hd.Model = wmi_HD("Model").ToString()
hd.Type = wmi_HD("InterfaceType").ToString()
hd.PhysicalDrive = wmi_HD("DeviceID").ToString()
hd.MediaType = wmi_HD("MediaType").ToString()
hd.Name = wmi_HD("Name").ToString()
hd.SystemName = wmi_HD("SystemName").ToString()
hd.Caption = wmi_HD("Caption").ToString()
hdCollection.Add(hd)
Next
' extract the serial number from Win32_PhysicalMedia class
Dim searcher2 As New ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia")
Dim i As Integer = 0
For Each wmi_HD As ManagementObject In searcher2.Get()
' get the hard drive from collection
' using index
Dim hd As HDClass = DirectCast(hdCollection(i), HDClass)
' get the hardware serial no.
If wmi_HD("SerialNumber") Is Nothing Then
hd.Serial = "None"
Else
hd.Serial = wmi_HD("SerialNumber").ToString()
End If
i += 1
Next
The problem is that I can't get the logical path like "c:", just the physicalpath: \\.\PHYSICALDRIVE0
How can I get the logical drive letter from the physical path?