今天夜里两点,还没有入睡,就把取得序列号的代码简单写了一下,没有分别在不同的系统上调试,只在win2000下调试通过,如果有问题的话,请告诉我,我再修改
1.调用diskid.dll实现:
Option Explicit Private Declare Function IsWinNT Lib "DiskID.DLL" () As Long Private Declare Function ReadPhysicalDrive9X Lib "DiskID.DLL" (driveID As Long, buffer As Long, bufLen As Long) As Long Private Declare Function ReadPhysicalDriveInNT Lib "DiskID.DLL" (driveID As Long, buffer As Long, 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
Private Sub Command1_Click() Dim x As DRIVER_INFO_OK Dim i As Long If IsWinNT = 1 Then i = ReadPhysicalDriveInNT(ByVal 0, ByVal VarPtr(x), ByVal 256) Else i = ReadPhysicalDrive9X(ByVal 0, ByVal VarPtr(x), ByVal 256) End If
|