给您一段我的示例代码:
Initialize事件代码:
if GetConfigValue("Count",0)=0
SaveConfigValue("系统路径",ProjectPath)
SaveConfigValue("提示音","3")
end if项目发布前:命令窗口执行:SaveConfigValue("Count",0) ‘初始化项目启动次数为0次,这是关键一步,每次发布前操作并存盘。
AfterOpenProject事件代码:
Dim n As Integer = GetConfigValue("Count",1)
Dim Code As String = GetConfigValue("认证码" & ComputerId,"")
Dim Ok As Boolean
If n < 6 Then
Forms("系统设置").Open()
Else
if n = 30
if MessageBox.show(" 编程不再是您的梦想,编程不再是程序员的专利,您也" & Chr(13) & Chr(10) & "能编写出这样的游戏程序,不信请登录狐表官方论坛!","友情提示",MessageBoxButtons.OK) = 1
Dim Proc As New Process '定义一个新的Process
Proc.File = "http://www.foxtable.com/index.asp" '指定要打开的网页地址
Proc.Start()
SaveConfigValue("Count",0)
end if
else
if n > 50
if MessageBox.show(" 您正免费使用金亿通娱乐软件之拼图游戏,欢迎" & Chr(13) & Chr(10) & "经常登录金亿通软件工作室网站查看更新情况!","友情提示",MessageBoxButtons.OK) = 1
Dim Proc As New Process '定义一个新的Process
Proc.File = "http://www.jinyit.cn" '指定要打开的网页地址
Proc.Start()
SaveConfigValue("Count",0)
end if
else
If Code > "" And code =EncryptText(mid(ComputerId,7,1) & mid(ComputerId,2,1) & mid(ComputerId,5,1) & mid(ComputerId,3,1) & mid(ComputerId,9,1) & mid(ComputerId,1,1) & mid(ComputerId,11,1) & mid(ComputerId,6,1),"拼图cxg197168","拼图cxg710808").Replace("=","").Replace("/","").Replace("\","").Replace("-","").Replace("+","").Replace("÷","").Replace("×","").Replace("*","").ToUpper()
Ok = true
Forms("系统设置").Open()
Else
If n > 5 Then
Forms("系统注册").Open()
Code = GetConfigValue("认证码" & ComputerId,"")
If Code > "" AndAlso code =EncryptText(mid(ComputerId,7,1) & mid(ComputerId,2,1) & mid(ComputerId,5,1) & mid(ComputerId,3,1) & mid(ComputerId,9,1) & mid(ComputerId,1,1) & mid(ComputerId,11,1) & mid(ComputerId,6,1),"拼图cxg197168","拼图cxg710808").Replace("=","").Replace("/","").Replace("-:special:1:-,"").Replace("-","").Replace("+","").Replace("÷","").Replace("×","").Replace("*","").ToUpper() Then '如果注册码正确
Ok = true
Forms("系统注册").Open()
End If
End If
If n > 10 AndAlso Ok = False Then
MessageBox.show("该软件已超过使用次数!")
Syscmd.Project.Exit(true)
End If
End If
end if
end if
end if
n = n + 1
SaveConfigValue("Count",n)
上述代码实现系统注册、试用限制全过程。
注:在系统设计代码中需要应用系统路径的地方,全部采用GetConfigValue("系统路径",ProjectPath)
这样您的系统不但支持安装在任意路径,而且,启动一次后,.table文件可以复制到本机任意位置独立使用(采用了复杂的截面图片不可以,需要用到图片的地方都要指定这个路径)
也许还有更好的办法,我暂时没有深入地研究!