elliot315
Mr. Question
- Local time
- Today, 11:53
- Joined
- Jun 3, 2007
- Messages
- 98
I found this code, it is supposed to get the serial number of the HDD
I want to create a form that shows me that serial number to create an unlocking code for that installed db.
Any help on this will be appreciated.. where do I have to put this code, how to create the form that shows me the serial number, how to accept the unlocking number based on the math formula, and how to make this form not to appear after entering the correct code... I'm new in the scene of Access so I need very detailed instructions, thanks.
Private Const MAX_PATH = 260
Function fVolume1(strDriveLetter As String) As String
' Function to return the volume label for a drive
' Accepts:
' strDriveLetter - a valid drive letter for the PC, in the format "C:\"
' Returns:
' The volume label if it exists, or else "No label"
Dim strVolume As String
strVolume = Dir(strDriveLetter, vbVolume)
If strVolume = "" Then strVolume = "No label"
fVolume1 = strVolume
End Function
Function fVolume2(strDriveLetter As String) As String
' Function to return the volume label for a drive
' Accepts:
' strDriveLetter - a valid drive letter for the PC, in the format "C:\"
' Returns:
' The volume label if it exists, or else "No label"
Dim lngReturn As Long, lngDummy1 As Long, lngDummy2 As Long, lngDummy3 As Long
Dim strVolume As String, strDummy As String
strVolume = Space(MAX_PATH)
strDummy = Space(MAX_PATH)
lngReturn = apiGetVolumeInformation(strDriveLetter, strVolume, Len(strVolume), lngDummy1, lngDummy2, lngDummy3, strDummy, Len(strDummy))
strVolume = Left(strVolume, InStr(strVolume, vbNullChar) - 1)
If strVolume = "" Then strVolume = "No label"
fVolume2 = strVolume
End Function
Function fSerialNumber(strDriveLetter As String) As String
' Function to return the serial number for a hard drive
' Accepts:
' strDriveLetter - a valid drive letter for the PC, in the format "C:\"
' Returns:
' The serial number for the drive, formatted as "xxxx-xxxx"
Dim lngReturn As Long, lngDummy1 As Long, lngDummy2 As Long, lngSerial As Long
Dim strDummy1 As String, strDummy2 As String, strSerial As String
strDummy1 = Space(MAX_PATH)
strDummy2 = Space(MAX_PATH)
lngReturn = apiGetVolumeInformation(strDriveLetter, strDummy1, Len(strDummy1), lngSerial, lngDummy1, lngDummy2, strDummy2, Len(strDummy2))
strSerial = Trim(Hex(lngSerial))
strSerial = String(8 - Len(strSerial), "0") & strSerial
strSerial = Left(strSerial, 4) & "-" & Right(strSerial, 4)
fSerialNumber = strSerial
End Function
I want to create a form that shows me that serial number to create an unlocking code for that installed db.
Any help on this will be appreciated.. where do I have to put this code, how to create the form that shows me the serial number, how to accept the unlocking number based on the math formula, and how to make this form not to appear after entering the correct code... I'm new in the scene of Access so I need very detailed instructions, thanks.
Private Const MAX_PATH = 260
Function fVolume1(strDriveLetter As String) As String
' Function to return the volume label for a drive
' Accepts:
' strDriveLetter - a valid drive letter for the PC, in the format "C:\"
' Returns:
' The volume label if it exists, or else "No label"
Dim strVolume As String
strVolume = Dir(strDriveLetter, vbVolume)
If strVolume = "" Then strVolume = "No label"
fVolume1 = strVolume
End Function
Function fVolume2(strDriveLetter As String) As String
' Function to return the volume label for a drive
' Accepts:
' strDriveLetter - a valid drive letter for the PC, in the format "C:\"
' Returns:
' The volume label if it exists, or else "No label"
Dim lngReturn As Long, lngDummy1 As Long, lngDummy2 As Long, lngDummy3 As Long
Dim strVolume As String, strDummy As String
strVolume = Space(MAX_PATH)
strDummy = Space(MAX_PATH)
lngReturn = apiGetVolumeInformation(strDriveLetter, strVolume, Len(strVolume), lngDummy1, lngDummy2, lngDummy3, strDummy, Len(strDummy))
strVolume = Left(strVolume, InStr(strVolume, vbNullChar) - 1)
If strVolume = "" Then strVolume = "No label"
fVolume2 = strVolume
End Function
Function fSerialNumber(strDriveLetter As String) As String
' Function to return the serial number for a hard drive
' Accepts:
' strDriveLetter - a valid drive letter for the PC, in the format "C:\"
' Returns:
' The serial number for the drive, formatted as "xxxx-xxxx"
Dim lngReturn As Long, lngDummy1 As Long, lngDummy2 As Long, lngSerial As Long
Dim strDummy1 As String, strDummy2 As String, strSerial As String
strDummy1 = Space(MAX_PATH)
strDummy2 = Space(MAX_PATH)
lngReturn = apiGetVolumeInformation(strDriveLetter, strDummy1, Len(strDummy1), lngSerial, lngDummy1, lngDummy2, strDummy2, Len(strDummy2))
strSerial = Trim(Hex(lngSerial))
strSerial = String(8 - Len(strSerial), "0") & strSerial
strSerial = Left(strSerial, 4) & "-" & Right(strSerial, 4)
fSerialNumber = strSerial
End Function