option explicit
private type browseinfo
hwndowner 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 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(hwndowner as long, sprompt as string) as string
'定義變數
dim inull as integer
dim lpidlist as long
dim lresult as long
dim spath as string
dim udtbi as browseinfo
'初始化.....
with udtbi
.hwndowner = hwndowner
.lpsztitle = lstrcat(sprompt, "")
.ulflags = bif_returnonlyfsdirs
end with
'呼叫api
lpidlist = shbrowseforfolder(udtbi)
'得到返回結果
if lpidlist then
spath = string$(max_path, 0)
lresult = shgetpathfromidlist(lpidlist, spath)
call cotaskmemfree(lpidlist)
inull = instr(spath, vbnullchar)
if inull then spath = left$(spath, inull - 1)
end if
browseforfolder = spath
end function
private sub cmdselfile_click()
dim strresfolder as string
strresfolder = browseforfolder(hwnd, "請選擇系統安裝所在的目錄...")
if strresfolder = "" then
txtpath.text = ""
else
txtpath.text = strresfolder
end if
end sub
private sub form_load()
txtpath.text = ""
end sub
VB 選擇目錄對話方塊實現(API)
private type browseinfo hwndowner aslong pidlroot aslong pszdisplayname aslong lpsztitle aslong ulflags aslong lpfncallback aslong lparam aslong iimag...
Apache下實現禁止目錄瀏覽
當我們訪問某個 時,在後面增加相應的目錄,就可以瀏覽到目錄,對於 來說,是很不安全的。解決辦法 1 編輯httpd.conf檔案 找到如下內容 b b possible values for the options directive are none all or any combination ...
vb選擇檔案路徑
option explicit private const bif returnonlyfsdirs 1 private const bif dontgobelowdomain 2 private const max path 260 private declare function shbrows...