As the title says it, i am working in vb.net and trying to get the RPM of my hard disk in a textbox. Next to that i am trying to figure out if my disk is a HDD or SSD.
I have been searching the web a full week now on anything i can think of and all i can find is temperature reading using:
Const TEMPERATURE_ATTRIBUTE As Byte = 115
Public Function GetDriveTemp() As String
Dim retval As String = "Temp: "
Try
Dim searcher As New ManagementObjectSearcher("root\WMI", "SELECT * FROM MSStorageDriver_ATAPISmartData")
'loop through all the hard disks
For Each queryObj As ManagementObject In searcher.[Get]()
Dim arrVendorSpecific As Byte() = DirectCast(queryObj.GetPropertyValue("VendorSpecific"), Byte())
'Find the temperature attribute
Dim tempIndex As Integer = Array.IndexOf(arrVendorSpecific, TEMPERATURE_ATTRIBUTE)
retval = (arrVendorSpecific(tempIndex + 5))
Next
Catch err As ManagementException
Console.WriteLine("An error occurred while querying for WMI data: " + err.Message)
End Try
Return retval
End Function
I know Byte 115 is hdd temp, but i cannot find out what all other Bytes represent. Anybody any idea?
I need to know how i can search for SSD specific Values that a normal HDD doesn't have. I know there are, but i can't seem to find anything.
And next to that i need to find out what the RPM is of a HDD(not ssd)
There seems to be a better way these days (C#):
using (var partitionSearcher = new ManagementObjectSearcher(
@"\\localhost\ROOT\Microsoft\Windows\Storage",
$"SELECT DiskNumber FROM MSFT_Partition WHERE DriveLetter='{upperCaseDiskLetter}'"))
{
var partition = partitionSearcher.Get().Cast<ManagementBaseObject>().Single();
using (var physicalDiskSearcher = new ManagementObjectSearcher(
@"\\localhost\ROOT\Microsoft\Windows\Storage",
$"SELECT Size, Model, MediaType FROM MSFT_PhysicalDisk WHERE DeviceID='{ partition["DiskNumber"] }'"))
{
var physicalDisk = physicalDiskSearcher.Get().Cast<ManagementBaseObject>().Single();
var isSsd =
(UInt16)physicalDisk["MediaType"] == 4 ||
SSDModelSubstrings.Any(substring => result.Model.ToLower().Contains(substring)); ;
}
}
Based on same underlying types, but somewhat simpler in PowerShell:
$is_disk_C_SSD = (Get-PhysicalDisk | ?{$_.DeviceId -eq (Get-Partition -DriveLetter 'C')[0].DiskNumber})[0].MediaType -eq 'SSD'