Unique Hard Drive Serial (1 Viewer)

skea

Registered User.
Local time
Today, 16:52
Joined
Dec 21, 2004
Messages
342
I have seen some API that gets the serial of the hard drive, but this information is not unique and changes when the volume is formated.
Does any one know of a way to return the orignal manufucture's information/serial which is unique(GUID) to the volume.
Any Idea will be highly appreciated.
 
Last edited:

allan57

Allan
Local time
Today, 14:52
Joined
Nov 29, 2004
Messages
336
Function GetDriveVolumeSerialNumber()
'You must set the reference to 'Microsoft Scripting Runtime'
Dim fs As New FileSystemObject
Dim drvDrive As Drive
Dim strPath As String

On Error GoTo ErrorDetected

strPath = Environ("SystemDrive")
Set drvDrive = fs.GetDrive(strPath)
GetDriveVolumeSerialNumber = drvDrive.SerialNumber

MsgBox (GetDriveVolumeSerialNumber)

Exit Function

ErrorDetected:

MsgBox Err.Number & " - " & Err.Description

End Function
 

ghudson

Registered User.
Local time
Today, 09:52
Joined
Jun 8, 2002
Messages
6,195
We had a good thread on this subject in the old visual basic forum before it was hacked. I use the same as above execpt I also get the hex number. Can you verify if this gives you the actual serial number of the hard drive?

Code:
Function sGetVolumeSerialNumber()
'Must set a reference to the 'Microsoft Scripting Runtime'
 
    Dim fs As New FileSystemObject
    Dim x As Drive
    Dim sPath As String
    
    sPath = Environ("SystemDrive")
    Set x = fs.GetDrive(sPath)
    sGetVolumeSerialNumber = x.SerialNumber
 
    MsgBox Hex(sGetVolumeSerialNumber) 'Hex number
    MsgBox (sGetVolumeSerialNumber)
 
End Function
 

skea

Registered User.
Local time
Today, 16:52
Joined
Dec 21, 2004
Messages
342
Thanks ghudson and allan57, i like it because its short and easy to understand but unfortunately it gives the same value(of only drive c) as the API and not the actual value of the serial number.
Any more Ideas!!!
 

skea

Registered User.
Local time
Today, 16:52
Joined
Dec 21, 2004
Messages
342
According to different softwares i used,my HDD Firmware Serial Number is:WD-WMAJD2070320.
The one i get from the API is 471403277 which changes if i format my hard drive or if i replace the OS.
I know about the famous GetDiskSerial.dll which needs a purchase but any idea how i can get the former is highly appreciated??
 

ghudson

Registered User.
Local time
Today, 09:52
Joined
Jun 8, 2002
Messages
6,195
Search the VBnet site for the Obtaining a SMART IDE Drive's Serial Number function.

Please post back if it works for you.
 

skea

Registered User.
Local time
Today, 16:52
Joined
Dec 21, 2004
Messages
342
Thanks Thanks ghudson.
It worked a treat.
Just hoping that every client PC has a SMART HDD.:D
 
Last edited:

Users who are viewing this thread

Top Bottom