Get Hard Drive Serial Number Delphi

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. I have question how to generate unique serial number of machine in Delphi? I tried to do this using the ID the motherboard or processor, but unfortunately it's unfortunately supported. Partition serial numbers, etc. Fall off, because it is changing after the formatted.
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). Zrazok rezyume supervajzera. 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. 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.