Alex Rivera | Logout

Get HDD (and NOT Volume) Serial Number on Vista Ultimate 64 bit

Asked 2009-04-23T14:37:52.047
10

I was once looking for getting the HDD serial number without using WMI, and I found it. The code I found and posted on StackOverFlow.com works very well on 32 bit Windows, both XP and Vista. The trouble only begins when I try to get the serial number on 64 bit OSs (Vista Ultimate 64, specifically). The code returns String.Empty, or a Space all the time.

Anyone got an idea how to fix this?

EDIT:

I used the tools Dave Cluderay suggested, with interesting results:

Here is the output from DiskId32, on Windows XP SP2 32-bit:

To get all details use "diskid32 /d"
Trying to read the drive IDs using physical access with admin rights
Drive 0 - Primary Controller -  - Master drive
Drive Model Number________________: [MAXTOR STM3160215AS]
Drive Serial Number_______________: [            6RA26XK3]
Drive Controller Revision Number__: [3.AAD]
Controller Buffer Size on Drive___: 2097152 bytes
Drive Type________________________: Fixed
Drive Size________________________: 160041885696 bytes

Trying to read the drive IDs using the SCSI back door

Drive 4 - Tertiary Controller -  - Master drive
Drive Model Number________________: [MAXTOR STM3160215AS]
Drive Serial Number_______________: [            6RA26XK3]
Drive Controller Revision Number__: [3.AAD]
Controller Buffer Size on Drive___: 2097152 bytes
Drive Type________________________: Fixed
Drive Size________________________: 160041885696 bytes

Trying to read the drive IDs using physical access with zero rights

**** STORAGE_DEVICE_DESCRIPTOR for drive 0 ****
Vendor Id = []
Product Id = [MAXTOR STM3160215AS]
Product Revision = [3.AAD]
Serial Number = []

**** DISK_GEOMETRY_EX for drive 0 ****
Disk is fixed
DiskSize = 160041885696

Trying to read the drive IDs using Smart

Drive 0 - Primary Controller -  - Master drive

Drive Model Number________________: [MAXTOR STM3160215AS]
Driv
Edit
Report

2 Answers

3
answered 2009-04-28T06:16:33.663
1

Got working on Windows 7 64:

        ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");

        foreach (ManagementObject obj in mos.Get()) {
            Trace.TraceInformation("Information about disk drive {0}:", obj["Name"]);
            Trace.Indent();
            foreach (PropertyData pd in obj.Properties)
                Trace.TraceInformation("Name \"{0}\": \"{1}\"", pd.Name, pd.Value);
            Trace.Unindent();

            obj.Properties["SerialNumber"]
        }

Probably the class Win32_PhysicalMedia is not served on 64 bit platforms.

Even Disk32, at this time, is working (apart a bug when flipping serial number bytes), because is based on the same concepts.

answered 2010-06-13T21:18:10.657

Your Answer