Serial number of Harddrive

  • Thread starter Thread starter Evgeny Zoldin
  • Start date Start date
E

Evgeny Zoldin

Hi ALL,

how can I get serial number of harddrive using "pure" .NET, without Win API?

Thanx
 
Hi ALL,

how can I get serial number of harddrive using "pure" .NET, without Win API?

Thanx
using System.Management;
//be sure to reference the System.Managment.dll

string GetSerialNumber(string drive)
{
ManagementObject disk=new
ManagementObject("win32_logicaldisk.deviceid=\"" + drive + ":\"");
return
disk.Properties["VolumeSerialNumber"].Value.ToString());
}
 
Also check out the other properties of some of the other WMI classes
(Win32_PhysicalMedia or Win32_DiskDrive), as you might find ID that isn't
related to the logical volume. Not all devices give an asset tag or Serial
number, but you can try. The volume serial is easily changed.
-mike
MVP

Austin Ehlers said:
Hi ALL,

how can I get serial number of harddrive using "pure" .NET, without Win API?

Thanx
using System.Management;
//be sure to reference the System.Managment.dll

string GetSerialNumber(string drive)
{
ManagementObject disk=new
ManagementObject("win32_logicaldisk.deviceid=\"" + drive + ":\"");
return
disk.Properties["VolumeSerialNumber"].Value.ToString());
}
 
You told as volume serial is easily changed. It is probably true and also
very interesting and would like to know how?

Thanks,
Mirko

Michael Giagnocavo said:
Also check out the other properties of some of the other WMI classes
(Win32_PhysicalMedia or Win32_DiskDrive), as you might find ID that isn't
related to the logical volume. Not all devices give an asset tag or Serial
number, but you can try. The volume serial is easily changed.
-mike
MVP

Austin Ehlers said:
Hi ALL,

how can I get serial number of harddrive using "pure" .NET, without Win API?

Thanx
using System.Management;
//be sure to reference the System.Managment.dll

string GetSerialNumber(string drive)
{
ManagementObject disk=new
ManagementObject("win32_logicaldisk.deviceid=\"" + drive + ":\"");
return
disk.Properties["VolumeSerialNumber"].Value.ToString());
}
 
Back
Top