To supply SHBrowseForFolder with a proper start folder, I searched for SHGetIDListFromPath and found no official version but an undocumented reference to ordinal #162 in Shell32.dll
The good news is it works under Win7 :biggrin:
The bad news is it's pretty useless, you see the dialog and the folder, but you cannot go anywhere else, it's the only folder available :(
Any ideas? Special flags etc? I attach a test program, curious to see which Windows versions support it. Might produce an exception - who knows what happens inside Shell32 ;)
include \masm32\MasmBasic\MasmBasic.inc ; download (http://masm32.com/board/index.php?topic=94.0) (version 24 August needed)
.data?
bInfo BROWSEINFO <>
buffer db MAX_PATH dup(?)
Init
Dll "Shell32" ; #162 found in some VB forums
Declare #162=SHGetIDListFromPathW, 1
mov bInfo.pidlRoot, SHGetIDListFromPathW(wChr$("C:\Masm32\Examples"))
mov edi, offset buffer
mov bInfo.pszDisplayName, edi
mov bInfo.lpszTitle, Chr$("Select a folder")
invoke SHBrowseForFolder, addr bInfo
.if eax
invoke SHGetPathFromIDList, eax, edi
.else
mov edi, Chr$("Nothing selected")
.endif
Inkey "Selected folder: [", edi, "]"
Exit
end start
Assuming this is what you actually want to do, have some code ;)
.IF (eax == BFFM_INITIALIZED)
invoke SendMessage, hwnd,BFFM_SETSELECTION,TRUE,lpData
.ENDIF
Really cute trick, Tedd :t
In the meantime, I opted for GetOpenFileName (http://masm32.com/board/index.php?topic=626.0), simply because it allows to set wildcards (\Masm32\*.asm), too. Thanks a lot for BFFM_SETSELECTION, it will serve in another occasion ;-)
Still, I'd like to see an occasion where the pidlRoot method yields useful results :icon_cool: