⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 diskid.frm

📁 vb 获得硬盘出厂序列号,不是逻辑盘的序列号
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   4230
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   5910
   LinkTopic       =   "Form1"
   ScaleHeight     =   4230
   ScaleWidth      =   5910
   StartUpPosition =   3  '窗口缺省
   Begin VB.ListBox List1 
      Height          =   3120
      Left            =   120
      TabIndex        =   3
      Top             =   840
      Width           =   5655
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   3120
      TabIndex        =   1
      Text            =   "0"
      Top             =   120
      Width           =   615
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Read Disk"
      Height          =   375
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   975
   End
   Begin VB.Label Label1 
      Caption         =   "物理磁盘序号:"
      Height          =   375
      Left            =   1680
      TabIndex        =   2
      Top             =   240
      Width           =   1335
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
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
    Dim disknum As Integer
    disknum = Val(Text1.Text)
    If IsWinNT = 1 Then
        'i = ReadPhysicalDriveInNT(ByVal 0, ByVal VarPtr(x), ByVal 256)
        i = ReadPhysicalDriveInNT(ByVal disknum, ByVal VarPtr(x), ByVal 256)
    Else
        i = ReadPhysicalDrive9X(ByVal disknum, 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)
    List1.AddItem "硬件厂商代码为:" + s
    s = StrConv(x.SerialNumber, vbUnicode)
    s = Left(s, InStr(1, s, Chr(0)) - 1)
    List1.AddItem "硬盘序列号为:" + s

End Sub


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -