Every computer equipment has single and unique manufacture
code by which we can identify computer.It is mostly used to prevent pirated
sales of license of application. Here
we will learn to get hard disc serial code using vb 6.0.
Here is Function which returns serial number of HDD.
Public
Function GetDriveSerialNumber(Optional ByVal DriveLetter As String) As Long
Dim fso As Object, Drv As Object
'Create a FileSystemObject object
Set fso =
CreateObject("Scripting.FileSystemObject")
'Assign the current drive letter if not specified
If DriveLetter <> ""
Then
Set Drv =
fso.GetDrive(DriveLetter)
Else
Set Drv =
fso.GetDrive(fso.GetDriveName(App.Path))
End If
With Drv
If .IsReady Then
DriveSerial = Abs(.SerialNumber)
Else '"Drive Not Ready!"
DriveSerial = -1
End If
End With
'Clean up
Set Drv = Nothing
Set fso = Nothing
GetDriveSerialNumber = DriveSerial
End Function
Private
Sub Command1_Click()
MsgBox " Drive serial number for
" & Left(App.Path, 1) & ": " & GetDriveSerialNumber
End
Sub
New we can convert serial to hex value for more security and
compare with value we have already saved in variable.
Dim
serial as string
Serial
= “0054DRF000”
If
serial <> hex$(GetDriveSerialNumber
then)
Msgbox(“Invalid License”)
End
Endif
We simply call function and compare it to startup of application if serial can not
match vith stored variable value then exit program.
0 comments:
Post a Comment