Get Hard Disk Serial Number using HardDriveInfo Get hdd serial number delphi. DLL at SysTools Software. DLL successfully reads hard disk serial number. 0 Comments Leave a Reply. Write something about yourself. No need to be fancy, just an overview. December 2018.
HiI want to retrieve HDD unique (hardware) serial number.I use some functions but in Windows Seven or Vista they don't work correctly because of admin right.Is it possible retrieve it without run as Administrator?
Sertac Akyuz49.2k3 gold badges78 silver badges135 bronze badges
AminAmin7852 gold badges8 silver badges23 bronze badges
5 Answers
Following the links in the question comments Sertac posted, I came across this interesting C++ question, where Fredou answered with a nice link to a codeproject example showing how to do this in .NET, which in turn was based on a link to Borland C++ code and article.
The cool thing is that this C++ code works as a non-administrator user too!
Now you need someone to help you translate this C++ code to Delphi.
Edit: Found a Delphi unit that does this for you.
I wrote some sample use for it:
Unit from http://www.delphipraxis.net/564756-post28.html
Edit: RAID configurations require special provisions.
For instance, I got a RAID system with multiple RAID 5 array; only the first one displays, and it does not show the drive serial numbers, but the serial number of the RAID array:
--jeroen
Community♦
Jeroen Wiert PluimersJeroen Wiert Pluimers20.9k5 gold badges53 silver badges133 bronze badges
You can use the
WMI (Windows Management Instrumentation)
to get information related to windows hardware. Exist two wmi classes wich exposes a property called
SerialNumber
which store the Number allocated by the manufacturer to identify the physical media.
these classes are Win32_DiskDrive
and Win32_PhysicalMedia
.to access the SerialNumber
property of these classes you must know the DeviceId
of the Disk which is something like this .PHYSICALDRIVE0
. Another way is use a association class which link the Physical drive with the logical drive (C,D,E) so you must find this link previous to obtain the serial number. the sequence to find this association is like this.
Win32_DiskPartition
->Win32_LogicalDiskToPartition
->Win32_DiskDrive
Note 1 : The
SerialNumber
property for the Win32_DiskDrive
class does not exist in Windows Server 2003, Windows XP, Windows 2000, and Windows NT 4.0, so how you are talking about use Windows Vista or Windows 7, will work ok for you.Note 2 : The code does not require a administrator account to run.
check this code
RRUZRRUZ125k13 gold badges313 silver badges445 bronze badges
Here is another DiskId32 translation from C++ to Delphi by Victor Derevyanko
project:http://code.google.com/p/dvsrc/
Because the first method (WithZeroRights) doesn't work for me, I wrote another for ReadIdeDriveAsScsiDriveInNT method:
Sample usage:
This works great with my WD disk.
KachwahedKachwahed
I found this code, it is fixed one and working fine with me on windows 7 64
and this his all work
wahm sarabwahm sarab
Posting this purely for completeness sake, and to possibly satisfy those interested or die hard hardware fanatics.
I do not have a Pascal compiler at my disposal to test these routines on current Windows systems, but I do know this code worked back in the DOS era. Maybe it still works from a command prompt window.
Pascal code:
Please feel free to update this answer in order to get it working (if possible at all) in Delphi.
NGLNNGLN37.6k7 gold badges91 silver badges157 bronze badges
Not the answer you're looking for? Browse other questions tagged delphihardwaredelphi-7 or ask your own question.
How can I retrieve the manufacturer serial number of an USB flash drive in Delphi ?
I have tried this:
But it doesn't return correct result!
TLama65.8k15 gold badges167 silver badges302 bronze badges
opc0deopc0de7,0209 gold badges75 silver badges168 bronze badges
2 Answers
opc0de, according to your comments i will give you a sample using the WMI.
First, the code which you posted (using the
GetVolumeInformation
function) return the serial number assigned by windows when you format a disk.The good news are which exist two wmi classes wich exposes a property called
SerialNumber
which store the Number allocated by the manufacturer to identify the physical media.
these classes are Win32_DiskDrive
and Win32_PhysicalMedia
.Now the bad news, unfortunately this classes is not associated directly with the letter (C,D,E,F...) of the logical disk, because that you must call to another wmi classes to find the link between the logical driver letter and the Physical drive.
so you must find this link previous to obtain the serial number. the sequence to find this association is like this.
Win32_DiskPartition
->Win32_LogicalDiskToPartition
->Win32_DiskDrive
this is the code to obtain the serial number of a usb using the
Win32_DiskDrive
class.By the way some time ago i wrote an application called WMI Delphi Code Creator which can help you to generate delphi code to access the system info using the WMI.
UPDATE
Some drivers of the USB disks does not expose the manufacturer serial number on the Win32_DiskDrive.SerialNumber property, so on this cases you can extract the serial number from the
PnPDeviceID
property.Check this sample code.
RRUZRRUZ125k13 gold badges313 silver badges445 bronze badges
You can try the component TDiskInfo from GLib to Get the SerialNumber.
It not use WMI, but in some system (disk types) not retrieve the number.
Try it. It's free.
It not use WMI, but in some system (disk types) not retrieve the number.
Try it. It's free.
Regards.
![Get Serial Number Hdd Delphi Get Serial Number Hdd Delphi](/uploads/1/2/4/9/124929238/689981028.png)
Germán Estévez -Neftalí-Germán Estévez -Neftalí-