HDD manufacturer serial number

How to obtain the HDD manufacturer serial number which works for Extract physical serial number for IDE, RAID IDE, SCSI, RAID SCSI, SATA, RAID SATA, SATA2, RAID SATA2, SATA3, RAID SATA3 in Windows 98, ME, NT, 2000, 2003, 2008, XP, Vista, 7 in DELPHI.

in both 32 or 64 OS.
Please provide me the source code in DELPHI.

PS :Do not give me the source code which based on volume C or D or E drives.
Who is Participating?
DavidConnect With a Mentor PresidentCommented:
This isn't possible or practical for all hardware.  Every RAID controller has vendor-specific APIs, and not all controllers even have the intelligence or architecture to facilitate pass-through commands to get to the disks.

Now getting JBOD is a different thing entirely, .. but it is a lot of work (I know, I've done it, plus have support for maybe a dozen RAID controllers).   but this would still require thousands of hours of development time.  ATA/IDE/SATA uses one family of IOCTLS, and is easiest, but WinME/Win9x uses different code from WInNT/2K'  same source code can be used between win 2k/2k3/2k8, but Vista/Win7 needs to be a little different;

SCSI/SAS/FC/USB-attached  uses SCSI command-set.  ATA/SATA/IDE uses ATA command-set.  But even on JBOD, SATA disks may use SCSI command-set depending on the motherboard & controller.

The location of serial numbers is standardized for disks that speak the native ATA commands, but the SCSI spec allows serial numbers to be in one of several places, so you have to go through a list of a dozen places.

Also if you are using 64-bit O/S then pass-through commands don't work properly, so you have to make sure your source code compiles.

So just forget this project, the best you can do is read serial numbers from the registry, but all anybody has to do is change the registry entry and the info is not valid.  Also in many cases, depending on the specific O/S & hardware config, the registry entries are also wrong.

ThommyConnect With a Mentor Commented:
Check following resources...

Retrieving volume's (disk / drive) serial number

Read HDD serial number

IDE harddisk serial number

How can I get H.D.D serial number and CPU serial too?
WEBINAR: GDPR Implemented - Tips & Lessons Learned

Join the WatchGuard team on Thursday, March 29th as we recount some valuable lessons learned in weighing the needs of a business against the new regulatory environment, look ahead at the two months left before implementation, and help you understand the steps you can take today!

DavidConnect With a Mentor PresidentCommented:
I response to the other advice
1) Retrieving the volume serial number is useless, as this can be changed any time via the registry
2) The ReadHDD seriial # logic is CORRECT.  However it is only valid for ATA/SATA, but this IOCTL will not work for WinMe -> Win7.  MSFT has other IOCTLs, depending on what O/S you have.  
Also the IOCTL will break for a SAS+SATA controller, and SCSI, FC, SAS controllers.  It only deals with the ATA command0set

The IDE link includes other code for the older MS O/Ss, but it still won't help with anything but a direct-connect non-RAID ATA/IDE drive.  It also has same constraints I mentioned before.

I object, the answer #34939113 is correct.  Nothing on the planet will work with everything, because it is all vendor/product specific, but feel free to award points to other authors as they did provide links to some code that will work for a few types of non-RAID disks.
sidhiAuthor Commented:
How about the SATA ? Any source code ?
DavidConnect With a Mentor PresidentCommented:
SATA is where it starts to get difficult, because you have to use different pass-through code depending on whether the disk is emulating an IDE disk using the ATA instruction set, or if it is attached to a SAS/SATA controller; or a RAID controller in non-RAID mode, or RAID controller in RAID mode.

If RAID controller, then it is vendor specific.  Beyond that, if it is attached to a SAS/SATA controller you have to "speak" SCSI commands to it, and encapsulate SATA commands, which may be 12 or 16 bytes long, depending on controller.   The problem, is if you take a shortcut and just speak to the disk as if it is a SCSI-attached SATA, then the serial number field typically isn't available.  It can be in one of a half-dozen places, it it is anywhere at all.    The bridge chips used by the SATA disks on the SAS/SATA controllers aren't all standardized.

So I don't have anything I can (well, am willing to give you), as the only code that I know of that handles it is stuff that I wrote, and there are thousands of lines of code relating to discovery alone.  

(That is another issue .. you have to FIND the drive, and then query the hardware to figure out what interface it uses.  Even a complete discovery is going to take several hundred lines of code, because you don't want it to break if somebody is doing things like using software based RAID, or a disk is spundown/failed'; or a RAID controller is attached
sidhiAuthor Commented:
If that's so why the Seagate / WD were able to make a program named drivedetect (seagate) or datalifeguard(WD). Which both of them able to read our HDD serial number ?

for examples :
- WD the HDD serial number is like WD-WCAYU4xxxxxx
- Seagate the HDD serial number is like  5YD2xxxx

So how to get the Manufacture Serial Number ?

PS : Seagate HDD serial number almost similar with the one mentioned above about Volume Serial Number.
DavidConnect With a Mentor PresidentCommented:
That program only works with a few interface types.  It certainly does not work with RAID, nor will it work with all bridge chips, not by a long shot.  It wont work with most HP controllers, even if they are in NON-RAID mode.

Too many options.  I assure you to get the little that SEAGATE returns, you are talking hundreds of hours worth of development, and that is just for WinXP+.
32 vs 64 bit is different.
The low-level APIs are different for Win2K/NT, then WinXP.  It isn't even possible to compile a program that will support even all the 32-bit operating systems, with just a single transport, unless the program basically is a wrapper that includes programs compiled with the various WinDDK libraries.

Look, you are asking for a program that runs on every flavor of windows on the planet, that works with all possible proprietary disk interfaces, whether open, closed, with or without documentation, that can query internal fields that may not even exist in the first place.    I forgot to mention, there is no requirement for a unique serial number in some versions of the specs, so you WILL find disks that don't have it no matter what.

In my opinion the points should be splitted!!!
sidhiAuthor Commented:
should be spiltted... then any body know how to get the SN from SATA HDD for Win XP only on Delphi ?
same issue doing a SATA HDD for ANY operating system.  There are many ways to connect an ATA device, and the protocol changes with the type of physical connection.  A SATA disk will speak SCSI protocol if the disk is attached to a SAS/SATA controller, or in general if attached to any kind of RAID controller.  But attach it to a USB enclosure, and you need a huge database of vendor-specific stuff to determine what pass-thr0ugh mechanism is appropriate
sidhiAuthor Commented:
Just make it simple. anybody has the source code in DELPHI so I could get the HDD Serial Number ?
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.