以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  按天数加密软件  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=148179)

--  作者:zyxhx
--  发布时间:2020/4/1 17:00:00
--  按天数加密软件
老师,您好!
以下代码是帮助文件中的按试用次数加密,我想改为按试用天数加密,且写入系统注册表,请老师指点该如何修改?谢谢!

\'超过试用次数注册
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 > 50 Then
Messagebox.Show("您已经试用" & n & "次!总试用次数为88次!为了不影响您正常使用,请尽完成注册!")
Forms("注册").Open()
Code = GetConfigValue("Register" & ComputerId,"")
If Code > "" AndAlso DecryptText(Code,"abc","abc") = ComputerId Then \'如果注册码正确
OK = True
End If
End If
If n > 8 AndAlso Ok = False Then
Messagebox.Show("您正在使用的产品已经超出试用次数!")
Syscmd.Project.Exit()
End If
End If
n = n + 1
SaveConfigValue("Count",n)

--  作者:有点蓝
--  发布时间:2020/4/1 17:33:00
--  
试试
Dim s As String = GetConfigValue("Count","")
Dim d As Date = Date.Today
If s > "" Then
    If Date.TryParse(s,d) = False Then
        Messagebox.Show("试用日期设置无效!")
        Syscmd.Project.Exit()
    End If
Else
    SaveConfigValue("Count",Format(d,"yyyy-MM-dd"))
End If
Dim Code As String = GetConfigValue("Register" & ComputerId,"")
Dim Ok As Boolean
If Code > "" AndAlso DecryptText(Code,"abc","abc") = ComputerId Then \'如果注册码正确
    OK = True
Else
Dim tp As TimeSpan = Date.Today - d
    If tp.TotalDays > 50 Then
        Messagebox.Show("您已经试用" & n & "次!总试用次数为88次!为了不影响您正常使用,请尽完成注册!")
        Forms("注册").Open()
        Code = GetConfigValue("Register" & ComputerId,"")
        If Code > "" AndAlso DecryptText(Code,"abc","abc") = ComputerId Then \'如果注册码正确
            OK = True
        End If
    End If
    If tp.TotalDays > 88 AndAlso Ok = False Then
        Messagebox.Show("您正在使用的产品已经超出试用次数!")
        Syscmd.Project.Exit()
    End If
End If


--  作者:zyxhx
--  发布时间:2020/4/1 21:52:00
--  
提示天数数据好象不对:
图片点击可在新窗口打开查看此主题相关图片如下:提示.png
图片点击可在新窗口打开查看

用的以下代码:
Dim s As String = GetConfigValue("Count","")
Dim d As Date = Date.Today
If s > "" Then
    If Date.TryParse(s,d) = False Then
        Messagebox.Show("试用日期设置无效!")
        Syscmd.Project.Exit()
    End If
Else
    SaveConfigValue("Count",Format(d,"yyyy-MM-dd"))
End If
Dim Code As String = GetConfigValue("Register" & ComputerId,"")
Dim Ok As Boolean
If Code > "" AndAlso DecryptText(Code,"abc","abc") = ComputerId Then \'如果注册码正确
    OK = True
Else
Dim tp As TimeSpan = Date.Today - d
    If tp.TotalDays > 50 Then
        Messagebox.Show("您已经试用" & tp.TotalDays & "天!总试用天数为373915天!为了不影响您正常使用,请尽快完成注册!")
        Forms("注册").Open()
        Code = GetConfigValue("Register" & ComputerId,"")
        If Code > "" AndAlso DecryptText(Code,"abc","abc") = ComputerId Then \'如果注册码正确
            OK = True
        End If
    End If
    If tp.TotalDays > 373985 AndAlso Ok = False Then
        Messagebox.Show("您正在使用的产品已经超出试用天数!")
        Syscmd.Project.Exit()
    End If
End If

[此贴子已经被作者于2020/4/1 22:28:27编辑过]

--  作者:有点蓝
--  发布时间:2020/4/2 9:48:00
--  
用的以下代码:
Dim s As String = GetConfigValue("Count","")
msgbox(s) ‘显示什么内容

使用天数计算,有个问题,如果用户改了电脑时间呢,不就可以一直使用了?

--  作者:zyxhx
--  发布时间:2020/4/2 10:35:00
--  
是的,老师,这的确是个漏洞,还是使用试用次数比较安全。
--  作者:2900819580
--  发布时间:2020/4/2 10:50:00
--  

其实用GetConfigValue 也是一样的,软件重装又可以再使用N次。

 

软件加密还是建议用注册表和指定文件加密保存,这样的方法应该是目前最简有比较好效果的了。

 


--  作者:zyxhx
--  发布时间:2020/4/2 16:10:00
--  

谢谢