By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,361 Members | 1,683 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,361 IT Pros & Developers. It's quick & easy.

Serial number of Harddrive

P: n/a
Hi ALL,

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

Thanx
Jul 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Sat, 29 Nov 2003 03:02:29 +0100, "Evgeny Zoldin"
<ez*****@hotmail.com> wrote:
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());
}
Jul 21 '05 #2

P: n/a
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" <th***********************@hotmail.com> wrote in message
news:fu********************************@4ax.com...
On Sat, 29 Nov 2003 03:02:29 +0100, "Evgeny Zoldin"
<ez*****@hotmail.com> wrote:
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());
}

Jul 21 '05 #3

P: n/a
mp
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 [MVP]" <mg*******@Atrevido.net> wrote in message
news:uZ**************@tk2msftngp13.phx.gbl...
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" <th***********************@hotmail.com> wrote in message
news:fu********************************@4ax.com...
On Sat, 29 Nov 2003 03:02:29 +0100, "Evgeny Zoldin"
<ez*****@hotmail.com> wrote:
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());
}


Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.