我写了一个程序 想在启动时需要输入注册码才能使用 实现软件注册功能 使一个注册码对应一台机器 比如这个注册码必须在相应的硬盘序列号下才能生效
我是新手 希望把实例发到szzhouwenqiang@gmail.com
我这个是利用每一台机子都有唯一对应cpu序列号,来计算得到注册码,注册成功后,它会向注册表写入注册信息,下次启动不再弹出注册窗口,否则将弹出错误窗口并自动结束程序。
代码程序已发给你
这是一个实例软件代码:
Private Sub Form_Load()
j = GetSetting("MyApp1", "Startup", "b")
If j = "1" Then
Form1.Show
Else
Call jiance
End If
End Sub
Private Sub jiance()
Dim cpuSet
Dim cpu
Set cpuSet = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_Processor")
For Each cpu In cpuSet
a = (cpu.ProcessorId)
Next
For i = 1 To Len(a)
c = c & Asc(Mid(a, i, 1))
Next
a = InputBox("请输入注册码")
If a = c Then
Form1.Show
SaveSetting "MyApp1", "Startup", "b", "1"
Else
MsgBox "注册码错误"
End
End If
End Sub
这是计算注册码的代码:
Private Sub Command1_Click()
Dim cpuSet
Dim cpu
Set cpuSet = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_Processor")
For Each cpu In cpuSet
a = (cpu.ProcessorId)
Next
Print "cpu序列号为:" & a; ""
For i = 1 To Len(a)
c = c & Asc(Mid(a, i, 1))
Next
Text1 = "与此对应的注册码为:" & c
End Sub
代码程序已发给你
这是一个实例软件代码:
Private Sub Form_Load()
j = GetSetting("MyApp1", "Startup", "b")
If j = "1" Then
Form1.Show
Else
Call jiance
End If
End Sub
Private Sub jiance()
Dim cpuSet
Dim cpu
Set cpuSet = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_Processor")
For Each cpu In cpuSet
a = (cpu.ProcessorId)
Next
For i = 1 To Len(a)
c = c & Asc(Mid(a, i, 1))
Next
a = InputBox("请输入注册码")
If a = c Then
Form1.Show
SaveSetting "MyApp1", "Startup", "b", "1"
Else
MsgBox "注册码错误"
End
End If
End Sub
这是计算注册码的代码:
Private Sub Command1_Click()
Dim cpuSet
Dim cpu
Set cpuSet = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_Processor")
For Each cpu In cpuSet
a = (cpu.ProcessorId)
Next
Print "cpu序列号为:" & a; ""
For i = 1 To Len(a)
c = c & Asc(Mid(a, i, 1))
Next
Text1 = "与此对应的注册码为:" & c
End Sub
温馨提示:答案为网友推荐,仅供参考
第1个回答 2011-01-03
实例已发送,请查收。
本回答被网友采纳第2个回答 2011-01-04
Give me a mial, i send the form to u.
Happyq6@163.com
Option Explicit
Public LoginSucceeded As Boolean
Private Sub cmdCancel_Click()
'ÉèÖÃÈ«¾Ö±äÁ¿Îª false
'²»Ìáʾʧ°ÜµÄµÇ¼
LoginSucceeded = False
Me.Hide
End Sub
Private Sub cmdOK_Click()
'¼ì²éÕýÈ·µÄÃÜÂë
If txtPassword = "password" Then
'½«´úÂë·ÅÔÚÕâÀï´«µÝ
'³É¹¦µ½ calling º¯Êý
'ÉèÖÃÈ«¾Ö±äÁ¿Ê±×îÈÝÒ×µÄ
LoginSucceeded = True
Me.Hide
Else
MsgBox "ÎÞЧµÄÃÜÂ룬ÇëÖØÊÔ!", , "µÇ¼"
txtPassword.SetFocus
SendKeys "+"
End If
End Sub
Happyq6@163.com
Option Explicit
Public LoginSucceeded As Boolean
Private Sub cmdCancel_Click()
'ÉèÖÃÈ«¾Ö±äÁ¿Îª false
'²»Ìáʾʧ°ÜµÄµÇ¼
LoginSucceeded = False
Me.Hide
End Sub
Private Sub cmdOK_Click()
'¼ì²éÕýÈ·µÄÃÜÂë
If txtPassword = "password" Then
'½«´úÂë·ÅÔÚÕâÀï´«µÝ
'³É¹¦µ½ calling º¯Êý
'ÉèÖÃÈ«¾Ö±äÁ¿Ê±×îÈÝÒ×µÄ
LoginSucceeded = True
Me.Hide
Else
MsgBox "ÎÞЧµÄÃÜÂ룬ÇëÖØÊÔ!", , "µÇ¼"
txtPassword.SetFocus
SendKeys "+"
End If
End Sub