Delphi Hard Disk Serial Number
I'm trying to read serial no of the hard disk as a unique id of the machine. BSectorCountReg: BYTE; // IDE sector count register bSectorNumberReg: BYTE; // IDE sector number register bCylLowReg: BYTE; // IDE low order cylinder value. I built the code segment by using Delphi XE 7 and tested it on my. CodeFoot.com - Software, JavaScript, and Delphi Resources.
It’s surprisingly a non-trivial issue to retrieve the manufacturer’s information from a hard drive. Some people recommend using the API function. The problem is that this is not the serial number printed on the hard drive and assigned by the manufacturer, but is (according to the MSDN documentation): This function returns the volume serial number that the operating system assigns when a hard disk is formatted. To programmatically obtain the hard disk’s serial number that the manufacturer assigns, use the Windows Management Instrumentation (WMI) property SerialNumber. Notice also that it recommends to use the WMI Win32_Physical Media property “SerialNumber” to obtain the manufacturer’s serial. Interestingly enough,. The reason is that this property is optionally defined by the manufacturer and must be supplied by the hard disk driver.
So if we can’t use GetVolumeInformation() and we can’t rely on WMI 100% of the time, what can we do? Well, it involves querying several sources of information on a system directly. It also means we have to care if the drive is SATA, IDE, etc. Well, the smart folks at, wore an open-source application called DiskId32: DiskId32 is a Win32 console utility for reading the manufacturer’s information from your hard drives. It runs under Windows 9X, Win NT, Win 2K and Win XP (Pro/Home).
DiskId32 does not run on plain old DOS and I highly doubt that it works on Windows 3.x. It does NOT require administrator rights for Win NT/2K. I have seen this application recommended on many occasions, although there are that use similar methods. There is an open-source application called DiskID32 that is written in C++. Looking at the source code, it takes many scenarios in mind when attempting to retrieve disk information. It also works on Vista and Windows 7.
You can find full history on the application and it’s change-log here: Of course, I don’t expect you to convert it to Delphi.. However, if you from his website, you will have to fix 1 error in “ hwid_impl.pas” on line 1504.
The BROKEN CODE is: while ((HardDriveSerialNumber[ip] Chr(0)) and (ip Chr(0)) and (ip. Thamarai Serial Actors Name. Function GetIdeDiskSerialNumber: string; type TSrbIoControl = packed record HeaderLength: ULONG; Signature: array[0.7] of Char; Timeout: ULONG; ControlCode: ULONG; ReturnCode: ULONG; Length: ULONG; end; SRB_IO_CONTROL = TSrbIoControl; PSrbIoControl = ^TSrbIoControl; TIDERegs = packed record bFeaturesReg: Byte; // Used for specifying SMART 'commands'. BSectorCountReg: Byte; // IDE sector count register bSectorNumberReg: Byte; // IDE sector number register bCylLowReg: Byte; // IDE low order cylinder value bCylHighReg: Byte; // IDE high order cylinder value bDriveHeadReg: Byte; // IDE drive/head register bCommandReg: Byte; // Actual IDE command. BReserved: Byte; // reserved for future use. Must be zero. End; IDEREGS = TIDERegs; PIDERegs = ^TIDERegs; TSendCmdInParams = packed record cBufferSize: DWORD; // Buffer size in bytes irDriveRegs: TIDERegs; // Structure with drive register values. BDriveNumber: Byte; // Physical drive number to send command to (0,1,2,3).
BReserved: array[0.2] of Byte; // Reserved for future expansion. DwReserved: array[0.3] of DWORD; // For future use. BBuffer: array[0.0] of Byte; // Input buffer.
Comments are closed.