홈 · 개발 참고자료

개발 참고자료

[파워빌더] Browse for a folder using the standard Win dialog

작성자
관리자
작성일
2016-10-22
조회
10284
분류
파워빌더
[External FUNCTION declaration]
FUNCTION long SHGetPathFromIDListA (long pidl, ref string pszPath) &
LIBRARY "shell32.dll"
FUNCTION long SHBrowseForFolderA ( BROWSEINFO lpBrowseInfo) &
LIBRARY "shell32.dll"

[structure BROWSEINFO]
howner long
pidlroot long
pszdisplayname string
lpsztitle string
ulflags long
lpfn long
lparam long
iimage long

[Powerscript]
browseinfo lst_bi
long ll_pidl
int li_thispos
string ls_path, ls_xs
long ll_rc

ls_path=space(512) // maximum path lenght
lst_bi.howner=handle(this) // handle of the window
lst_bi.pidlRoot = 0
lst_bi.pszdisplayname = space(260)
lst_bi.lpszTitle = "Select a folder"
lst_bi.ulFlags = 1
ll_pidl = SHBrowseForFolderA(lst_bi)
ll_rc = SHGetPathFromIDListA(ll_pidl, ls_path)
IF NOT ll_rc > 0 THEN
SetNull(ls_path)
END IF
MessageBox("Folder selected" , ls_path)

NOTE: This may cause some memory leaks. To fix them, use the following API.[external function declaration]
SUBROUTINE CoTaskMemFree( long lpv ) LIBRARY "ole32.dll"

[powerscript]
SHBrowseForFolder( lst_bi )
CoTaskMemFree( lst_bi.pidlRoot )