惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
博客园 - Franky
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
L
LangChain Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
AI
AI
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs

博客园 - Lesliedi

GetDiskFreeSpaceEx的使用 项目管理怎么可以这样子! 小笨妞 浪费 夏走了 工作 走马观花------博 开始 换了 Byb F1---无言 asp.net中MultiPage 和TabStrrip的使用问题 为了花朵能灿烂地绽放 - Lesliedi 做吧,不要再想了 KIMI的那只轮胎 嗯..It was acclaimed as a discovery by someone!
查找文件夹
Lesliedi · 2006-10-16 · via 博客园 - Lesliedi

查找文件夹

Option Explicit
   
  Private Type BrowseInfo
          lngHwnd                 As Long
          pIDLRoot               As Long
          pszDisplayName   As Long
          lpszTitle             As Long
          ulFlags                 As Long
          lpfnCallback       As Long
          lParam                   As Long
          iImage                   As Long
  End Type
   
  Private Const BIF_RETURNONLYFSDIRS = 1
‘Private Const BIF_RETURNONLYFSDIRS = 100-----〉多一个新建文件夹的按钮
  Private Const MAX_PATH = 260
   
  Private Declare Sub CoTaskMemFree Lib "ole32.dll" _
          (ByVal hMem As Long)
   
  Private Declare Function lstrcat Lib "Kernel32" _
        Alias "lstrcatA" (ByVal lpString1 As String, _
        ByVal lpString2 As String) As Long
         
  Private Declare Function SHBrowseForFolder Lib "shell32" _
        (lpbi As BrowseInfo) As Long
         
  Private Declare Function SHGetPathFromIDList Lib "shell32" _
        (ByVal pidList As Long, ByVal lpBuffer As String) As Long
   
  Public Function BrowseForFolder(ByVal lngHwnd As Long, ByVal strPrompt As String) As String
   
          On Error GoTo ehBrowseForFolder         'Trap   for   errors
   
          Dim intNull     As Integer
          Dim lngIDList     As Long, lngResult       As Long
          Dim strPath     As String
          Dim udtBI     As BrowseInfo
   
          'Set   API   properties   (housed   in   a   UDT)
          With udtBI
                  .lngHwnd = lngHwnd
                  .lpszTitle = lstrcat(strPrompt, "")
                  .ulFlags = BIF_RETURNONLYFSDIRS
          End With
   
          'Display   the   browse   folder...
          lngIDList = SHBrowseForFolder(udtBI)
   
          If lngIDList <> 0 Then
                  'Create   string   of   nulls   so   it   will   fill   in   with   the   path
                  strPath = String(MAX_PATH, 0)
   
                  'Retrieves   the   path   selected,   places   in   the   null
                    'character   filled   string
                  lngResult = SHGetPathFromIDList(lngIDList, strPath)
   
                  'Frees   memory
                  Call CoTaskMemFree(lngIDList)
   
                  'Find   the   first   instance   of   a   null   character,
                    'so   we   can   get   just   the   path
                  intNull = InStr(strPath, vbNullChar)
                  'Greater   than   0   means   the   path   exists...
                  If intNull > 0 Then
                          'Set   the   value
                          strPath = Left(strPath, intNull - 1)
                  End If
          End If
   
          'Return   the   path   name
          BrowseForFolder = strPath
          Exit Function     'Abort
   
ehBrowseForFolder:
   
          'Return   no   value
          BrowseForFolder = Empty
   
  End Function
 
   
  Private Sub Command1_Click()
          Debug.Print BrowseForFolder(Me.hWnd, "a")
  End Sub

posted on 2006-10-16 18:29  Lesliedi  阅读(429)  评论()    收藏  举报