Two in the night, I haven't slept yet, I wrote the code that the serial number is simply written. I have no debugging on different systems. I only try to debug in Win2000. If there is a problem, please tell me again, I will modify it.
1. Call DISKID.DLL implementation:
Option ExplicitPrivate Declare Function IsWinNT Lib "DiskID.DLL" () As LongPrivate Declare Function ReadPhysicalDrive9X Lib "DiskID.DLL" (driveID As Long, buffer As Long, bufLen As Long) As LongPrivate Declare Function ReadPhysicalDriveInNT Lib "DiskID.DLL" (driveID As Long, Buffer As Long, Bufflen 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 LONGEND 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 DIM S AS STRING S = STRCONV (X.ModalNumber, Vbunicode) S = Left (s, INSTR (1, S, CHR (0)) - 1) MSGBOX "Hardware Vendor code is:" s s = strConv (X.Serialnumber, Vbunicode) s = left (s, INSTR (1, s, chr (0)) - 1) msgbox "Hard disk serial number is:" Send Sub
2. Call Diskid32.dll implementation:
Option ExplicitPrivate Declare Function Diskid32 Lib "Diskid32.dll" (byref diskmodel as byte, byref diskid as byte) As long
Private submmand1_click () DIM DiskModel (31) AS BYTE, DISTEGER, Model As String, ID AS String IF DISKID32 (DiskModel (0), Diskid (0)) <> 1 THEN MSGBOX " Get Diskid32 Err "EXIT SUB END IF I = 0 to 31 IF CHR (DiskModel (I)) <> CHR (0) THEN MODEL = Model & CHR (DiskModel (i)) END IF CHR (DiskID (i)) <> Chr (0) THEN ID = ID & ChR (DiskID (i)) end if next msgbox "hardware generating code is:" model msgbox "hard disk serial number:" IDEND SUB
Description: Diskid.dll can download from http://www.applevb.com/lib/diskio.rar, DISKID32.DLL can be downloaded from http://www.downez.com/down.asp?id=1149&no=1