Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi ..
I am running the "Get Hardware Information" EXE file.
I am trying to get the Hard Disk Serial Number, NOT Volume Serial Number.
I used the "Data Storage" Tab : "Win32_DiskDrive" Selection, which gave me strange Serial Number !!!
Appreciate your assistance.
Posted

 
Share this answer
 
Comments
Addy Tas 30-Nov-11 9:30am    
Short but complete answer. All you need to know is in there it seems.
Try this one :

C#
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;
}


Extracted from here :
http://stackoverflow.com/questions/1353881/how-do-i-use-c-sharp-to-get-the-hard-disk-serial-number[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900