一、开发思路:
获取计算机硬件信息加密后保存到参数表。
程序每次运行都获取当前计算机的硬件信息,加密后和参数表进行比对。
不匹配即显示注册窗体,不运行主程序。
匹配即运行主程序。
禁用《Soft_Register》窗体的右键菜单。
二、实现方法:
在 SysFrmLogin 窗体增加以下代码:代码中的PWkey值为自已的加密匙。需要自行修改。
Private Sub Form_Load()
If GetParameter("ComputerID") <> des(computerID(), "PWkey", doEncryption) Then
DoCmd.OpenForm "Soft_Register", acNormal
Else
Dim strFormName As String: strFormName = Me.Name
DoCmd.Close acForm, strFormName, acSaveNo
OpenRDPForm strFormName
End If
End Sub
复制增加《Soft_Register》窗体到自已的程序中。
代码中的PWkey值为自已的加密匙。需要自行修改。
Private Sub Form_Close()
If GetParameter("ComputerID") = des(computerID(), "PWkey", doEncryption) Then
MsgBox "注册激活成功!请重新打开软件。"
Else
MsgBox "注册激活失败!请重新打开软件进行注册激活使用。"
End If
End Sub
Private Sub Form_Load()
Me.ShortcutMenu = False
Me.registerID = GetParameter("ComputerID")
Me.Computer = computerID()
End Sub
Private Sub getRegister_Click()
Me.registerID = des(Me.Computer, "PWkey", doEncryption)
End Sub
Private Sub quit_Click()
Me.ShortcutMenu = True
DoCmd.quit acQuitSaveNone
End Sub
Private Sub Register_Click()
If des(Me.registerID, "PWkey", doDecryption) = Me.Computer Then
DoCmd.SetWarnings False
Dim strSQL
If GetParameter("ComputerID") <> des(computerID(), "PWkey", doEncryption) Then
strSQL = "update [SysLocalParameters] set [Value]='" & des(computerID(), "PWkey", doEncryption) & "' where [ParameterName]='ComputerID'"
DoCmd.RunSQL strSQL
End If
MsgBox "注册成功!"
blExit = True
Call LogoutRDP
Else
MsgBox "激活码有误,请重新录入!"
Me.Register.SetFocus
End If
End Sub
Private Sub WriteRegister_Click()
DoCmd.SetWarnings False
Dim strSQL
strSQL = "update [SysLocalParameters] set [Value]='' where [ParameterName]='ComputerID'"
DoCmd.RunSQL strSQL
Me.registerID = ""
End Sub
三、示例下载:
下载附件解压后,打开Main主程序文件就可以运行。
附 件:(UMVsoftRDP_V2.4.1.412_32bit)
点击下载此附件