I need to know sourcecode about getting "serial number" of harddisk. Please help me.
note:
1. "serial number" NOT "Volumn Serial Number"
2. each harddisk has id called serial number
3. Volumn Serial Number is generated by "format" command
Printable View
I need to know sourcecode about getting "serial number" of harddisk. Please help me.
note:
1. "serial number" NOT "Volumn Serial Number"
2. each harddisk has id called serial number
3. Volumn Serial Number is generated by "format" command
'ref to Microsoft Scripting Runtime
Sub ShowDriveInfo(drvpath)
Dim fs, d, s, t
set fs = CreateObject("Scripting.FileSystemObject")
set d = fs.GetDrive(fs.GetDriveName(fs.GetAbsolutePathName(drvpath)))
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
Iouri Boutchkine
[email protected]
Hello, Iouri.
The source code you have posted is "Volumn Serial Number" not "Serial Number" and i need " Harddisk Serial Number".
Thank You.
Who know? Please.
I used to write a prog that modifies hard drive or floppy Serial Number. The code that I gave you read this number correctly.
Iouri Boutchkine
[email protected]
I tried Iouris coed and it returned the drive serial number for me NOT its volume serial number.
Code output, in my case was
'
Drive C: - Fixed
SN: 982263575
'
'
My C: drives volume Serno is "Production"
John G
Thank you John. At least now I know that I am not going bananas.
Iouri Boutchkine
[email protected]
I tried Iouris coed and it returned the volume serial number.
Code output, in my case was
Drive C: - Fixed
SN: 220795131
Drive D: - Fixed
SN: 142088909
But my drive c and d are on the same harddisk (my harddisk has partioned to drive c and d)
the searial number i mean is unique Serial ID
'even this will bring up same result:
'you will get two different serail number for the two drives.
'It seems as if logical drives get their own serial number...
private Declare Function GetVolumeInformation Lib "Kernel32" Alias "GetVolumeInformationA" (byval lpRootPathName as string, byval lpVolumeNameBuffer as string, byval nVolumeNameSize as Long, lpVolumeSerialNumber as Long, lpMaximumComponentLength as Long, lpFileSystemFlags as Long, byval lpFileSystemNameBuffer as string, byval nFileSystemNameSize as Long) as Long
private Sub Form_Load()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: [email protected]
Dim Serial as Long, VName as string, FSName as string
'Create buffers
VName = string$(255, Chr$(0))
FSName = string$(255, Chr$(0))
'get the volume information
GetVolumeInformation "C:\", VName, 255, Serial, 0, 0, FSName, 255
'Strip the extra chr$(0)'s
VName = Left$(VName, InStr(1, VName, Chr$(0)) - 1)
FSName = Left$(FSName, InStr(1, FSName, Chr$(0)) - 1)
MsgBox "The Volume name of C:\ is '" + VName + "', the File system name of C:\ is '" + FSName + "' and the serial number of C:\ is '" + Trim(Str$(Serial)) + "'", vbInformation + vbOKOnly, App.Title
End Sub
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
:D There are thousands of questions and answers in the forum that looks to me the same:
"Get an unique PC number that doesn't change even if you reinstall Windows, format the drive or something like this."
And most of the answers aren't even close to this.
The Iouri's code returns Volume Serial Number that is generated when you format the volume. That means tha if you format your C: it will change his number!!!
I'm searching for a way (like Phogang does) to get the hardware's serial number. That mean the number that manufacturer of the HDD is give to it.
So, please stop posting messages with "GetVolumeInformation", "Scripting.FileSystemObject", etc.
That doesn't work the way we (me and probably Phogang) expect.
That mean Cimperiali too. Understand - this is not we looking for.
Hi to all,
yestarday i finally got something that is most like the HDD serial number (not the volume ser. num.)
Sorry but i have not enough time to check and test this but i hope it is what we looking for.
I found it on another vb source page, but i can't remember now (yestarday i browse more then 1000 pages :D ).
Ok. Bye.
This thread is too old. You've already posted a question. Don't double post.
well, I've looked at the source code for this program based on a referal to this thread.
The source code doesn't look for SATA I/II drives. The person who wrote the original
program before my post is NIKIDD. Thus, I thought he/she would see it and maybe
update their software they linked to along time ago. Particuliarily since in 2003
they didn't have SATA drives.