急,我想根据这个程序写一个根据硬盘号与mac地址生成注册号的程序

love_lrg 2009-06-19 05:04:09
哪个高手帮帮我
现成的程序是:
Imports System.Management


Public Class Form1
Dim uint321 As UInt32
' My.Computer.FileSystem.WriteAllBytes("C:\MyDocuments\CustomerData", CustomerData, True)

Dim arByte(3) As Byte

Private Sub TableLayoutPanel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs)

End Sub

Private Sub btnReg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReg.Click
'获得硬盘序列号

Dim cmicWmi As New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")

For Each cmicWmiObj As ManagementObject In cmicWmi.Get
uint321 = cmicWmiObj("signature")
Next

TextBox1.Text = uint321.ToString

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'生成注册文件放到程序目录
Dim file1 As New FileIO.FileSystem
If Dir("reports.dat", FileAttribute.Hidden) <> "" Then
'删除 注册文件
SetAttr("reports.dat", FileAttribute.Archive)

End If
arByte(0) = uint321 And &HFF
uint321 = uint321 >> 8
arByte(1) = uint321 And &HFF
uint321 = uint321 >> 8
arByte(2) = uint321 And &HFF
uint321 = uint321 >> 8
arByte(3) = uint321 And &HFF

My.Computer.FileSystem.WriteAllBytes("reports.dat", arByte, False)
'FileOpen(1, "reports.dat", OpenMode.Output)
''Write(1, 232)
'Write(1, uint321)
'FileClose(1)
SetAttr("reports.dat", FileAttribute.Hidden)


End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox3.Text = GetReg(uint321)
End Sub
Function GetReg(ByVal MachineNo As UInt32) As String
Dim x As UInt32
Dim ret As String
ret = ""
x = 67452301
MachineNo = MachineNo Xor x
Dim by(32) As Byte
Dim k As Integer
For k = 0 To 31
by(k) = MachineNo Mod 2
MachineNo /= 2
Next
Dim info As Byte
' Dim m As Char
For k = 0 To 31 Step 4
info = CByte(by(k + 3) * (2 ^ 3) + by(k + 2) * (2 ^ 2) + by(k + 1) * 2 + by(k))
ret = ret & Chr(info + 65)
Next
Return ret

End Function

Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
Me.Close()
End
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'验证
If YanZhen() Then
MsgBox("成功")
End If
End Sub

Function YanZhen() As Boolean
'验证程序的合法性
Dim myID As UInteger
YanZhen = False '非法
Dim myar As Byte()
'FileOpen(1, "reports.dat", OpenMode.Input)
'Input(1, myID)
'不存在文件退出 返回失败
If Dir("reports.dat", FileAttribute.Hidden) = "" Then
Return False '非法
End If
myar = My.Computer.FileSystem.ReadAllBytes("reports.dat")
If myar.Length < 4 Then
Return False '非法
End If
myID = myar(3)
myID <<= 8
myID += myar(2)
myID <<= 8
myID += myar(1)
myID <<= 8
myID += myar(0)

Dim cmicWmi As New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")

For Each cmicWmiObj As ManagementObject In cmicWmi.Get
If myID = cmicWmiObj("signature") Then
YanZhen = True
End If
Next

End Function

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
uint321 = CLng(TextBox1.Text.Trim)
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
MsgBox(PhysicalDrive.GetSerialNumber(0))
End Sub

Private Sub btnTry_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTry.Click
'试用
Dim myID As UInteger = 12346678
uint321 = myID
Dim file1 As New FileIO.FileSystem
If Dir("reports.dat", FileAttribute.Hidden) <> "" Then
'删除 注册文件
SetAttr("reports.dat", FileAttribute.Archive)

End If
arByte(0) = uint321 And &HFF
uint321 = uint321 >> 8
arByte(1) = uint321 And &HFF
uint321 = uint321 >> 8
arByte(2) = uint321 And &HFF
uint321 = uint321 >> 8
arByte(3) = uint321 And &HFF

My.Computer.FileSystem.WriteAllBytes("reports.dat", arByte, False)
'FileOpen(1, "reports.dat", OpenMode.Output)
''Write(1, 232)
'Write(1, uint321)
'FileClose(1)
SetAttr("reports.dat", FileAttribute.Hidden)

End Sub
End Class
...全文
100 15 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
zjljk2000 2010-01-22
  • 打赏
  • 举报
回复
学习
yanlongwuhui 2010-01-07
  • 打赏
  • 举报
回复
关键在取硬盘号与mac地址,算法可以自己编一个。硬盘号与mac地址都有些不足
kuhura 2010-01-07
  • 打赏
  • 举报
回复
先mark一下再说
ws9528 2010-01-06
  • 打赏
  • 举报
回复
关注很长时间了。
yurengang 2010-01-06
  • 打赏
  • 举报
回复
lang_csdn 2010-01-04
  • 打赏
  • 举报
回复
呵呵,我也想知道。帮顶!
love_lrg 2010-01-04
  • 打赏
  • 举报
回复
哎还是没啥
ntzrs 2009-07-03
  • 打赏
  • 举报
回复
在程序中是 解密 然后一个一个的比
ntzrs 2009-07-03
  • 打赏
  • 举报
回复
我用的是mac +版本号+ 客户名 后加密
ntzrs 2009-07-03
  • 打赏
  • 举报
回复
我用的是mac
bukuai009 2009-06-21
  • 打赏
  • 举报
回复
qikaa 2009-06-21
  • 打赏
  • 举报
回复
这个获取的是磁盘系统分区的序列号,不是硬盘的出厂id,一旦重装系统或重新分区,即要重新注册
hanjs 2009-06-20
  • 打赏
  • 举报
回复
我关注了,也想弄个注册的算法。

怎么能让使用的人必须得注册后才能用。
love_lrg 2009-06-19
  • 打赏
  • 举报
回复
如何根据这个程序改改呀,请高手快点抢分,回帖
love_lrg 2009-06-19
  • 打赏
  • 举报
回复
根据这个改改如何改呀

16,722

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧