Click here to Skip to main content
15,886,786 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Hi to all

I am trying to fetch serialno of hard disk I used Win32_PhysicalMedia
class the code is working perfectly fine with ide hard disk.
But when I use it for SATA it does not display the serial no. I downloaded other softwares which display serial no I want to use serial no of hard disk for security reasons for my softwares.

If any body have any Idea please help Me.....

Sorry for bad english

Thanks
Posted
Updated 27-Mar-10 0:00am
v2

You do know that the serial number changes every time you reformat the drive, right?
 
Share this answer
 
Hi,

be careful here, there are several traps.

1.
each partition has a serial number, that one is easy to get. It gets assigned when the partition gets formatted, hence it can change over time.

Most Google hits tend to point to the partition's serial number (as that is the easiest to get), without always making that clear.

2.
each physcial disk has a data structure, with one field holding the physical serial number. It requires the vendor's collaboration, which normally isn't a problem. AFAIK the number cannot change over time (unless you replace the device of course).

There are several ways to get it (using WMI, using device-level file operations), however each of those would require elevation on Vista and later systems.

:)
 
Share this answer
 
You can download WMI explorer (http://www.ks-soft.net/hostmon.eng/wmi/index.htm[^]) and find the serial number by yourself.
Hope this will help.
Best wishes!
 
Share this answer
 
Hi Dmitry Vitkovsky

I downloaded the file you asked to download but it is also not showing the result which I expected Is there any other way or which can solve my problem. Any way thanks for the reply...

This is my code which is I using to display serial number. It displays all other properties axcept serialnumber.

ManagementObjectSearcher searcher = new ManagementObjectSearcher();
            searcher.Query = new ObjectQuery("select * from Win32_PhysicalMedia ");
            foreach (ManagementObject obj in searcher.Get())
            {
                Console.WriteLine(obj["SerialNumber"]);
            }
 
Share this answer
 
v2
What is the possible way to identify a system uniquely?
 
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