急,我想根据这个程序写一个根据硬盘号与mac地址生成注册号的程序
哪个高手帮帮我
现成的程序是:
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