VB写了一个程序 现在想让程序提取用户的硬盘号生成一个注册码 发给用户 达到软件注册的目的!
展开全部
Option Explicit
Private Declare Function IsWinNT Lib "DiskID.DLL " () As Long
Private Declare Function ReadPhysicalDrive9X Lib "DiskID.DLL " _
(ByVal driveID As Long, ByVal lpBuffer As Long, ByVal bufLen As Long) As Long
Private Declare Function ReadPhysicalDriveInNT Lib "DiskID.DLL " _
(ByVal driveID As Long, ByVal lpBuffer As Long, ByVal bufLen As Long) As Long
Private Type DRIVER_INFO_OK
ModalNumber(39) As Byte
SerialNumber(19) As Byte
ControlNum(7) As Byte
DriveType As Long
Cylinders As Long
Heads As Long
Sectors As Long
End Type
Public Function GetDiskID_Demo()
'获取硬盘信息的演示程序。
Dim x As DRIVER_INFO_OK
Dim i As Long
If IsWinNT = 1 Then
i = ReadPhysicalDriveInNT(ByVal 0&, ByVal VarPtr(x), LenB(x))
Else
i = ReadPhysicalDrive9X(ByVal 0&, ByVal VarPtr(x), LenB(x))
End If
MsgBox "BufLen: " & LenB(x)
Dim s As String
s = StrConv(x.ModalNumber, vbUnicode)
s = Left(s, InStr(1, s, ChrW(0)) - 1)
MsgBox "硬件厂商代码为: " + s
s = StrConv(x.SerialNumber, vbUnicode)
s = Left(s, InStr(1, s, ChrW(0)) - 1)
MsgBox "硬盘序列号为: " + s
End Function
Private Declare Function IsWinNT Lib "DiskID.DLL " () As Long
Private Declare Function ReadPhysicalDrive9X Lib "DiskID.DLL " _
(ByVal driveID As Long, ByVal lpBuffer As Long, ByVal bufLen As Long) As Long
Private Declare Function ReadPhysicalDriveInNT Lib "DiskID.DLL " _
(ByVal driveID As Long, ByVal lpBuffer As Long, ByVal bufLen As Long) As Long
Private Type DRIVER_INFO_OK
ModalNumber(39) As Byte
SerialNumber(19) As Byte
ControlNum(7) As Byte
DriveType As Long
Cylinders As Long
Heads As Long
Sectors As Long
End Type
Public Function GetDiskID_Demo()
'获取硬盘信息的演示程序。
Dim x As DRIVER_INFO_OK
Dim i As Long
If IsWinNT = 1 Then
i = ReadPhysicalDriveInNT(ByVal 0&, ByVal VarPtr(x), LenB(x))
Else
i = ReadPhysicalDrive9X(ByVal 0&, ByVal VarPtr(x), LenB(x))
End If
MsgBox "BufLen: " & LenB(x)
Dim s As String
s = StrConv(x.ModalNumber, vbUnicode)
s = Left(s, InStr(1, s, ChrW(0)) - 1)
MsgBox "硬件厂商代码为: " + s
s = StrConv(x.SerialNumber, vbUnicode)
s = Left(s, InStr(1, s, ChrW(0)) - 1)
MsgBox "硬盘序列号为: " + s
End Function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2011-09-02
展开全部
VB写了一个程序 现在想让程序提取用户的硬盘号生成一个注册码 发给用户 达到软件注册的目的!
问迈谋适帖浆晨脱嫁劣
问迈谋适帖浆晨脱嫁劣
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询