|
我的文件不知道放哪里了,你改改就行Function GetSerialNumber(strDrive As String) As Long
Dim SerialNum As Long
Dim Res As Long
Dim Temp1 As String * MAX_FILENAME_LEN
Dim Temp2 As String * MAX_FILENAME_LEN
Res = GetVolumeInformation(strDrive, Temp1, _
Len(Temp1), SerialNum, 0, 0, Temp2, Len(Temp2))
GetSerialNumber = SerialNum
End Function
Private Sub cmdOK_Click()
n = Abs(GetSerialNumber(Left(App.Path, 3)))
For a = 1 To Len(n)
c = c + Mid(n, (Len(n) + 1) - a, 1)
Next
d = str(c)
p = 1
If Len(d) < 20 Then
d = d + String(20 - Len(d), "X")
ElseIf Len(d) > 20 Then
d = Left(d, 20)
End If
For i = 1 To 20
If Len(str(Asc(Mid(d, i, 1)))) > 3 Then
p = p + Mid(str(Asc(Mid(d, i, 1))), 2, 2) * 199
Else
p = p + Asc(Mid(d, i, 1)) * 199
End If
Next
If Val(Trim(strWRegistration.Text)) <> p Then
MsgBox "注册码错误!", vbCritical, "错误"
End
Else
SaveSetting "TransnationalProgram", "Registration", "RecogniseCode", p
SaveSetting "TransnationalProgram", "Registration", "UserName", Trim(strWUserName.Text)
MsgBox "请重新运行程序验证注册是否成功", vbInformation, "启动"
End
End If
End Sub
Private Sub Form_Load()
lblValidate.Caption = lblValidate.Caption + str(Abs(GetSerialNumber(Left(App.Path, 3))))
Me.Hide
SaveSetting "TransnationalProgram", "Registration", "Validate", str(Abs(GetSerialNumber(Left(App.Path, 3))))
n = Abs(GetSerialNumber(Left(App.Path, 3)))
For a = 1 To Len(n)
c = c + Mid(n, (Len(n) + 1) - a, 1)
Next
d = str(c)
p = 1
If Len(d) < 20 Then
d = d + String(20 - Len(d), "X")
ElseIf Len(d) > 20 Then
d = Left(d, 20)
End If
For i = 1 To 20
If Len(str(Asc(Mid(d, i, 1)))) > 3 Then
p = p + Mid(str(Asc(Mid(d, i, 1))), 2, 2) * 199
Else
p = p + Asc(Mid(d, i, 1)) * 199
End If
Next
If GetSetting("TransnationalProgram", "Registration", "RecogniseCode") <> p Then
MsgBox "未注册版本,请注册!", vbInformation, "注册"
Me.Show
Else
frmLogin1.Show
End If
End Sub
|
|