基本信息
源码名称:vb 打开选择文件夹弹窗并返回选中的文件夹
源码大小:0.46M
文件格式:.rar
开发语言:ASP
更新时间:2019-12-14
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍

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