Serial_Number = GetDriveInfo("C:\", GETDI_SERIAL) ' HD Serial Number Text1.Text = Str(Serial_Number) 'simple calculation ( do your own ) Activation_Code = Left(Serial_Number, 4) 'Left 4 digits Activation_Code = Activation_Code * 881999 'Multiply By 881999 Activation_Code = Left(Activation_Code, 6) 'Get the left 6 Numbers Only'check if user registerd before Get_Serial_From_Registry = GetSetting("App_Name", "Registration", "Code")
'If user already registerd then quit If Activation_Code = Get_Serial_From_Registry Then frmMain.Text1 = Serial_Number frmMain.Text2 = Activation_Code Unload Me frmMain.Show 'else show the HD serial code Else lbl_HD_Serial_Number = Serial_Number End If End Sub —————————————————————— 模块: Public Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerial_Numberber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long Public Const GETDI_SERIAL = 1 Public Const GETDI_LABEL = 2 Public Const GETDI_TYPE = 3 Function GetDriveInfo(strDrive As String, iType As Integer)
Dim Serial_Number As Long Dim Drive_Label As String Dim Fat_Type As String
http://www.setupfactory.net/download/index.php?theme=blue
Private Sub Form_Load()
Serial_Number = GetDriveInfo("C:\", GETDI_SERIAL) ' HD Serial Number
Text1.Text = Str(Serial_Number)
'simple calculation ( do your own )
Activation_Code = Left(Serial_Number, 4) 'Left 4 digits
Activation_Code = Activation_Code * 881999 'Multiply By 881999
Activation_Code = Left(Activation_Code, 6) 'Get the left 6 Numbers Only'check if user registerd before
Get_Serial_From_Registry = GetSetting("App_Name", "Registration", "Code")
'If user already registerd then quit
If Activation_Code = Get_Serial_From_Registry Then
frmMain.Text1 = Serial_Number
frmMain.Text2 = Activation_Code
Unload Me
frmMain.Show
'else show the HD serial code
Else
lbl_HD_Serial_Number = Serial_Number
End If
End Sub
——————————————————————
模块:
Public Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerial_Numberber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long
Public Const GETDI_SERIAL = 1
Public Const GETDI_LABEL = 2
Public Const GETDI_TYPE = 3
Function GetDriveInfo(strDrive As String, iType As Integer)
Dim Serial_Number As Long
Dim Drive_Label As String
Dim Fat_Type As String
Dim Return_Value As Long
Drive_Label = Space(256)
Fat_Type = Space(256)
Return_Value = GetVolumeInformation(strDrive, Drive_Label, Len(Drive_Label), Serial_Number, 0, 0, Fat_Type, Len(Fat_Type))
GetDriveInfo = CStr(Serial_Number)End Function
因为每次Format硬盘之后,序列号就会改变,导致安装序列号不一致!
还有,我也试过在不同的机器上的硬盘序列号会出现一样的情况!用硬盘序列号不是太可靠!