本程序采用Visual Basic编译

引用
 

 

1、在模块中加入以下声明

Public Declare Function GetVolumeInformation Lib "kernel32" _

Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, _

ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, _

lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, _

lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, _

ByVal nFileSystemNameSize As Long) As Long

'得到某磁盘的信息

引用
 

 

2、窗体代码

Option Explicit

Private Regid, Localid As Long

 
Sub Text2_KeyPress(KeyAscii As Integer)

If KeyAscii < 48 Or KeyAscii > 57 Then

KeyAscii = 0

End If

End Sub

'只接受数字输入

 
Private Sub Form_Load()

Dim Driver, VolName, Fsys As String

Dim volNumber, MCM, FSF As Long

Driver = "C:"

Dim res As Long

res = GetVolumeInformation(Driver, VolName, 127, volNumber, MCM, FSF, Fsys, 127)

'volNumber是C盘序列号

Text1.Text = Int(volNumber / 2 + 123456789)

End Sub

'读取C盘序列号,并根据一定的算法产生机器码

 
Private Sub CmdRegID_Click()

Dim Driver, VolName, Fsys As String

Dim volNumber, MCM, FSF As Long

Driver = "C:"

Dim res As Long

res = GetVolumeInformation(Driver, VolName, 127, volNumber, MCM, FSF, Fsys, 127)

If Val(Text2.Text) = Int(Val(Text1.Text) / 4 * 3 + 987654321) Then

MsgBox "恭喜你输入正确!"

Else

MsgBox "输入不对啦!"

End If

End Sub

'根据一定的算法产生注册码

 
Private Sub CmdCheckID_Click()

End

End Sub

'退出

Comments
Write a Comment