gcnagaraj
asked on
Hard Disk Serial Number
Hi
I am developing a software in VB for which i need the serial number of the hard disk. I searched thru the net and i was getting the programs which tell me the Volume Number of the drive (ie c: , d: etc). According to my information, this volume number changes whenever that volume is formatted. Can anybody help in getting the Hard Disk serial number which is manufacturer defined and which will not change
thx in advance
nagaraj
I am developing a software in VB for which i need the serial number of the hard disk. I searched thru the net and i was getting the programs which tell me the Volume Number of the drive (ie c: , d: etc). According to my information, this volume number changes whenever that volume is formatted. Can anybody help in getting the Hard Disk serial number which is manufacturer defined and which will not change
thx in advance
nagaraj
Another possibility:
Using FSO: http://msdn.microsoft.com/library/default.asp?URL=/library/devprods/vs6/vbasic/vbenlr98/vaproserialnumber.htm
Using FSO: http://msdn.microsoft.com/library/default.asp?URL=/library/devprods/vs6/vbasic/vbenlr98/vaproserialnumber.htm
That's correct, nagaraj -- the serial number returned by GetVolumeInformation is OS supplied and will change when that drive is partitioned. What you are looking for is a way to retrieve that data from the driver. Although I can't help you with the VB part here is the API call you should check out:
DeviceIoControl( ..., IOCTL_CHANGER_GET_PRODUCT_ DATA, ... ) -- not sure about the IOCTL_CHANGER_GET_PRODUCT_ DATA. The DeviceIoControl still gives you low-level access to devices so that should get you going.
.f
DeviceIoControl( ..., IOCTL_CHANGER_GET_PRODUCT_
.f
Are these api's not different then ?
GetVolumeInformation or GetVolumeSerialNumber !!!
GetVolumeInformation or GetVolumeSerialNumber !!!
Refer to this link
http://codeguru.com/system/DiskId32.shtml
http://codeguru.com/system/DiskId32.shtml
Dhaest,
nope -- they both return the OS provided volume serial number that gets changed when the drive is partitioned. Those API calls DO NOT return the hardware serial number of the drive.
a_pravarakhya provided the link to source code illustrating the use of DeviceIoControl() to retrieve the hardware serial number that stays constant throughout the life of the drive, no matter how many times it is partitioned, how many OS's ran on it or anything else.
.f
nope -- they both return the OS provided volume serial number that gets changed when the drive is partitioned. Those API calls DO NOT return the hardware serial number of the drive.
a_pravarakhya provided the link to source code illustrating the use of DeviceIoControl() to retrieve the hardware serial number that stays constant throughout the life of the drive, no matter how many times it is partitioned, how many OS's ran on it or anything else.
.f
And the code of the second link ? Does it provide the correct serialnumber or not ?
Sub ShowDriveInfo(drvpath)
Dim fs, d, s, t
Set fs = CreateObject("Scripting.Fi leSystemOb ject")
Set d = fs.GetDrive(fs.GetDriveNam e(fs.GetAb solutePath Name(drvpa th)))
Select Case d.DriveType
Case 0: t = "Unknown"
Case 1: t = "Removable"
Case 2: t = "Fixed"
Case 3: t = "Network"
Case 4: t = "CD-ROM"
Case 5: t = "RAM Disk"
End Select
s = "Drive " & d.DriveLetter & ": - " & t
s = s & vbCrLf & "SN: " & d.SerialNumber
MsgBox s
End Sub
Sub ShowDriveInfo(drvpath)
Dim fs, d, s, t
Set fs = CreateObject("Scripting.Fi
Set d = fs.GetDrive(fs.GetDriveNam
Select Case d.DriveType
Case 0: t = "Unknown"
Case 1: t = "Removable"
Case 2: t = "Fixed"
Case 3: t = "Network"
Case 4: t = "CD-ROM"
Case 5: t = "RAM Disk"
End Select
s = "Drive " & d.DriveLetter & ": - " & t
s = s & vbCrLf & "SN: " & d.SerialNumber
MsgBox s
End Sub
Nope, it doesn't -- it's also the OS provided one, subject to change on repartitioning.
.f
.f
Take the serial number of the computer it came out of or is in and go to the manufacturer and then the manufacturer will track it back to that subcomponent.
RIVER FREIGHT
RIVER FREIGHT
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hi All,
I am also looking for the exactly same solution. I came to this link via searching on net for the problem solution.
But, the URL giving as a solution of this problem is not working as it is quite long time after getting this solution.
So, any one of you, please give me that information/solution?
Awaiting for your valuable help.
thanks and regards,
Kruti.
I am also looking for the exactly same solution. I came to this link via searching on net for the problem solution.
But, the URL giving as a solution of this problem is not working as it is quite long time after getting this solution.
So, any one of you, please give me that information/solution?
Awaiting for your valuable help.
thanks and regards,
Kruti.
Public Function VolumeSerialNumber(ByVal RootPath As String) As String
Dim VolLabel As String
Dim VolSize As Long
Dim Serial As Long
Dim MaxLen As Long
Dim Flags As Long
Dim Name As String
Dim NameSize As Long
Dim s As String
If GetVolumeSerialNumber(Root
'Create an 8 character string
s = Format(Hex(Serial), "00000000")
'Adds the '-' between the first 4 characters and the last 4 characters
VolumeSerialNumber = Left(s, 4) + "-" + Right(s, 4)
Else
'If the call to API function fails the function returns a zero serial number
VolumeSerialNumber = "0000-0000"
End If
End Function
Private Sub Command1_Click()
MsgBox VolumeSerialNumber("C:\") 'Shows the serial number of your Hard Disk
End Sub