📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "文件夹浏览"
ClientHeight = 2295
ClientLeft = 45
ClientTop = 330
ClientWidth = 4035
Icon = "Form1.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2295
ScaleWidth = 4035
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command2
Caption = "退出"
Height = 495
Left = 1800
TabIndex = 1
Top = 1560
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "选择文件夹"
Height = 495
Left = 600
TabIndex = 0
Top = 1560
Width = 1215
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "你选择的文件夹是:"
Height = 180
Left = 600
TabIndex = 3
Top = 360
Width = 1620
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "Label1"
Height = 255
Left = 600
TabIndex = 2
Top = 840
Width = 3015
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 Sub Command1_Click()
Dim bi As BROWSEINFO
Dim pidl As Long
Dim path As String
Dim pos As Integer
Label1.Caption = ""
'初始化BROWSEINFO结构中的成员
'接收消息的窗口句柄,可以是应用程序的句柄
'或者从GetDesktopWindow()返回的句柄
bi.hOwner = Me.hWnd
'指向相对于浏览器中的“根”文件夹的位置的元素标志列表,
'如果本参数为NULL,则为桌面文件夹
bi.pidlRoot = 0&
'显示在浏览对话框中的消息
bi.lpszTitle = "请选择 Windows\System\ 目录"
'要返回的文件夹类型
bi.ulFlags = BIF_RETURNONLYFSDIRS
'显示浏览对话框
pidl = SHBrowseForFolder(bi)
'退出了浏览对话框,解析、显示用户选择的文件夹
path = Space$(MAX_PATH)
If SHGetPathFromIDList(ByVal pidl, ByVal path) Then
pos = InStr(path, Chr$(0))
Label1.Caption = Left(path, pos - 1)
End If
Call CoTaskMemFree(pidl)
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -