views:

1268

answers:

4

How do i get the hard disk serial number without using dll and supported by VISTA

+2  A: 

Try the code here and let us know if it works.

EDIT: And if that doesn't work, try this code from CodeProject.

Luke Girvin
+2  A: 

This is not c# but I am sure that it's very easy to translate. Here

You should use @Luke one. If it does not work then try this one.

Jonathan Shepherd
+6  A: 
using System.Management;

public string GetHDDSerial()
{
    ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia");

    foreach (ManagementObject wmi_HD in searcher.Get())
    {
        // get the hardware serial no.
        if (wmi_HD["SerialNumber"] != null)
            return wmi_HD["SerialNumber"].ToString();
    }

    return string.Empty;
}
Omar Fernando Pessoa
Yes, I agree... WMI.
Kris Krause
A: 

thank you so muche, that's work good for me

Zaki