📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "读出驱动器序列号"
ClientHeight = 2970
ClientLeft = 60
ClientTop = 345
ClientWidth = 3915
LinkTopic = "Form1"
ScaleHeight = 2970
ScaleWidth = 3915
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "读出"
Height = 375
Left = 1320
TabIndex = 2
Top = 1920
Width = 975
End
Begin VB.TextBox Text1
Height = 375
Left = 960
TabIndex = 1
Text = "c"
Top = 1080
Width = 855
End
Begin VB.Label Label2
Caption = "驱动器:"
Height = 375
Left = 360
TabIndex = 3
Top = 1200
Width = 735
End
Begin VB.Label Label1
Caption = "驱动器序列号"
Height = 255
Left = 2520
TabIndex = 0
Top = 1200
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
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
'代码如下:
Function GetSerialNumber(strDrive As String) As Long
Dim SerialNum As Long
Dim Res As Long
Dim Temp1 As String
Dim Temp2 As String
Temp1 = String$(255, Chr$(0))
Temp2 = String$(255, Chr$(0))
Res = GetVolumeInformation(strDrive, Temp1, _
Len(Temp1), SerialNum, 0, 0, Temp2, Len(Temp2))
GetSerialNumber = SerialNum
End Function
Private Sub Command1_Click()
Label1.Caption = GetSerialNumber(Text1.Text + ":\")
End Sub
Private Sub form_load()
'使用该函数:
'它将告诉磁盘序号。
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -