📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 3 'Fixed Dialog
Caption = "U盘序列号"
ClientHeight = 960
ClientLeft = 45
ClientTop = 450
ClientWidth = 4605
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 960
ScaleWidth = 4605
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox Text2
Height = 270
Left = 1080
TabIndex = 3
Text = "Text2"
Top = 480
Width = 3255
End
Begin VB.TextBox Text1
Height = 270
Left = 1080
TabIndex = 0
Text = "Text1"
Top = 120
Width = 3255
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "MD5加密:"
Height = 180
Left = 240
TabIndex = 2
Top = 480
Width = 810
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "U盘序列号:"
Height = 180
Left = 120
TabIndex = 1
Top = 120
Width = 990
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Function CC()
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_USBHub")
For Each objItem In colItems
a = objItem.DeviceID 'U盘识别为:USB\VID_09A6&PID_800\20040418154911-00,故用VID判别
If a Like "*VID*" Then b = Split(a, "\")
CC = b(UBound(b))
'上句亦可:If InStr(a, "VID") Then b = Split(a, "\"): MsgBox b(UBound(b))
Next
End Function
Private Sub Form_Load()
Text1.Text = CC
If Text1.Text = "" Then
MsgBox "请插入U盘"
End
End If
Text2.Text = MD5(CC, 32)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -