With the
Win32_LogicalDisk Management path we can reach the local disk information.
Even you can read
harddisk serial number,
size, partitions, free space and so on.
Now let's read the
serial number of a
harddisk in
C# with
ManagementClass WMI.
public static string HardDiskID()
{
ManagementClass partionsClass = new ManagementClass("Win32_LogicalDisk");
ManagementObjectCollection partions = partionsClass.GetInstances();
string hdd = string.Empty;
foreach (ManagementObject partion in partions)
{
hdd = Convert.ToString(partion["VolumeSerialNumber"]);
if (hdd != string.Empty)
return hdd;
}
return hdd;
}
This static function will simple give us the volume serial numbers.
C# Read Harddisk Serial Number WMI ManagementClass.