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

📄 获得磁盘序列号.frm

📁 Windows API函数,希望大伙有用哦
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   2415
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5280
   LinkTopic       =   "Form1"
   ScaleHeight     =   2415
   ScaleWidth      =   5280
   StartUpPosition =   3  '窗口缺省
   Begin VB.Frame Frame2 
      Caption         =   "磁盘序列号和文件系统类型:"
      Height          =   2055
      Left            =   1980
      TabIndex        =   2
      Top             =   150
      Width           =   2985
      Begin VB.TextBox Text2 
         Alignment       =   1  'Right Justify
         Height          =   315
         Left            =   1230
         TabIndex        =   4
         Text            =   "Text2"
         Top             =   1170
         Width           =   1515
      End
      Begin VB.TextBox Text1 
         Alignment       =   1  'Right Justify
         Height          =   315
         Left            =   1230
         TabIndex        =   3
         Text            =   "Text1"
         Top             =   450
         Width           =   1485
      End
      Begin VB.Label Label2 
         Caption         =   "文件系统:"
         Height          =   315
         Left            =   120
         TabIndex        =   6
         Top             =   1200
         Width           =   945
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "磁盘序列号:"
         Height          =   180
         Left            =   150
         TabIndex        =   5
         Top             =   510
         Width           =   1080
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "磁盘选择:"
      Height          =   2025
      Left            =   210
      TabIndex        =   0
      Top             =   180
      Width           =   1455
      Begin VB.DriveListBox Drive1 
         Height          =   300
         Left            =   180
         TabIndex        =   1
         Top             =   270
         Width           =   1065
      End
   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 GetVolumeInformation Lib "kernel32.dll" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Integer, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long
Private Sub Drive1_Change()
  GetSerialNumber Drive1 & "\"
End Sub
Private Sub Form_Load()
  Drive1 = "C:\"
  GetSerialNumber "C:\"
End Sub
Function GetSerialNumber(sRoot As String) As Long
Dim lSerialNum As Long, strtype As String, strlabel As String
  strtype = String$(255, Chr$(0))
  GetVolumeInformation sRoot, strlabel, Len(strlabel), lSerialNum, 0, 0, strtype, Len(strtype)
  '在 Text1中显示当前磁盘序列号
  Text1 = Hex$(lSerialNum)
  '在 Text2中显示当前磁盘的文件系统类型
  Text2 = strtype
End Function

⌨️ 快捷键说明

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