以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  如何实现注册表注册验证机制呢?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=133252)

--  作者:李孝春
--  发布时间:2019/4/10 17:17:00
--  如何实现注册表注册验证机制呢?
代码如下:怎么融合在一起 让信息写入注册表  根据注册表中的数据来进行软件注册与否的提示呢?

设置信息到注册表代码如下:

Dim Count As Integer
Count = Registry.GetValue("HKEY_CURRENT_USER\\Software\\MyApp","Count",0)
Registry.SetValue("HKEY_CURRENT_USER\\Software\\MyApp","Count",Count + 1)


项目的AfterOpenProject事件设为:

Dim n As Integer = GetConfigValue("Count",1)
Dim
Code As String = GetConfigValue("Register" & ComputerId,"")
Dim
Ok As Boolean
If
Code > "" AndAlso DecryptText(Code,"abc","abc") = ComputerId Then \'如果注册码正确
    OK =
True
Else
    If
n > 30 Then
        Forms(
"注册").Open()
        Code = GetConfigValue(
"Register" & ComputerId,"")
        If
Code > "" AndAlso DecryptText(Code,"abc","abc") = ComputerId Then \'如果注册码正确
            OK =
True
        End
If
    End
If
    If
n > 60 AndAlso Ok = False Then
        Messagebox.Show(
"您正在使用的产品已经超出试用次数!")
        Syscmd.Project.
Exit()
    End
If
End
If
n = n +
1
SaveConfigValue(
"Count",n)


--  作者:有点甜
--  发布时间:2019/4/10 18:05:00
--  
Dim n As Integer = Registry.GetValue("HKEY_CURRENT_USER\\Software\\MyAPP","Count",0)
Dim Code As String =Registry.GetValue("HKEY_CURRENT_USER\\Software\\MyAPP","Register" & HardDiskID,"")
Registry.SetValue("HKEY_CURRENT_USER\\Software\\MyAPP","Count", n+1)
Dim Ok As Boolean
If Code > "" AndAlso DecryptText(Code,"acbd","bad") = HardDiskID AndAlso Tables("注册用户信息表").Current IsNot Nothing Then \'如果注册码正确
    StatusBar.DefaultMessage ="POS机进销存管理系统 2.0    " & Tables("注册用户信息表").Current("公司名称")
    OK = True
Else
    If n >=20 AndAlso  n < 30  Then
        Forms("系统注册窗体").Open()
        Code = Registry.GetValue("HKEY_CURRENT_USER\\Software\\MyAPP","Register" & HardDiskID,"")
        If Code > "" AndAlso DecryptText(Code,"acbd","bad") = HardDiskID Then \'如果注册码正确
            StatusBar.DefaultMessage ="POS机进销存管理系统 2.0    " & Tables("注册用户信息表").Current("公司名称")
            OK = True
        End If
    ElseIf n >= 30 AndAlso Ok = False Then
        Dim Result As DialogResult
        Result = MessageBox.Show("您使用的软件已经超过使用次数,需要注册才能使用,是否注册?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        If Result = DialogResult.Yes Then
            Forms("系统注册窗体").Open()
            Code = Registry.GetValue("HKEY_CURRENT_USER\\Software\\MyAPP","Register" & HardDiskID,"")
            If Code > "" AndAlso DecryptText(Code,"acbd","bad") = HardDiskID AndAlso Tables("注册用户信息表").Current IsNot Nothing Then \'如果注册码正确
                StatusBar.DefaultMessage ="POS机进销存管理系统 2.0    " & Tables("注册用户信息表").Current("公司名称")
                OK = True
            Else
                Return
            End If
        Else
            System.Diagnostics.Process.GetCurrentProcess().Kill
        End If
    End If
    StatusBar.DefaultMessage ="POS机进销存管理系统 2.0     " & "              试用版"
End If