PDA

View Full Version : [Tutorial]API to Get Hard Drive Serial Number



Dxt-Cobra
09-14-2007, 09:05 AM
API to Get Hard Drive Serial Number
Use this code to get a hard drive, floppy, CD-ROM, ... serial number.


Private Declare Function GetVolumeInformation _
Lib "kernel32" Alias "GetVolumeInformationA" _
(ByVal lpRootPathName As String, _
ByVal pVolumeNameBuffer As String, _
ByVal nVolumeNameSize As Long, _
lpVolumeSerialNumber As Long, _
lpMaxComponentLentgh As Long, _
lpFileSysyemFlags As Long, _
ByVal lpFileSystemBuffername As String, _
ByVal nFileSystemNameSize As Long) As Long

Public Function GetSerialNumber(ByVal sDrive As String) As Long

If Len(sDrive) Then
If InStr(sDrive, "\\") = 1 Then
'Make sure we end in backslash for UNC
If Right$(sDrive, 1) <> "\" Then
sDrive = sDrive & "\"
End If
Else
'If not UNC take first letter as drive
sDrive = Left$(sDrive, 1) & ":\"
End If
Else
'Use current drive
sDrive = vbNullString
End If

Call GetVolumeInformation(sDrive, vbNullString, 0, GetSerialNumber, ByVal 0&, _
ByVal 0&, vbNullString, 0)
End Function

Private Sub Command1_Click()
Dim sDrive As String

sDrive = InputBox("Enter drive for checking SN")
MsgBox Hex$(GetSerialNumber(sDrive))
End Sub

sukh13
10-27-2007, 02:10 AM
hmm how to use this

SH15TER
11-10-2007, 07:02 PM
this is for in the Module,
to get Hard Drive Serial Number!!

[OWNAGE]
01-13-2008, 02:09 PM
this is for in the Module,
to get Hard Drive Serial Number!!

All good but this is Volume Serial number right?

You can change that :P

Wieter20
02-04-2008, 08:35 AM
i think its nice but not well explained how to do

btw i mean i positieve because i couldnt do this for shit..:P

zezima
03-18-2008, 01:33 PM
Thanks Cobra! This is a one long API! This thing is so easy to work with! Thanks A lot man!:DblueteamenforcerStr8

littlemast
06-11-2008, 06:28 PM
Thanks just what i need :P

kaswar
10-10-2008, 12:59 PM
Each pc has a different serial right?

Thanks, Been looking for this :)

NevaLess
10-10-2008, 02:00 PM
Each pc has a different serial right?

Thanks, Been looking for this :)

Yep, but the serial can be masked way to easily.
It's a yet very unsafe.
It does work though.

BazzleStag
07-07-2009, 09:31 PM
What port is the main computers serial? Cuz it asks me for a port.

marexblue
08-26-2009, 02:31 AM
just tested it in my vb6 ide. it works fine. for those lazy noob that cant able to figure this out. i attach a created project...


credit to dxt-cobra.