News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

SHGetIDListFromPath and SHBrowseForFolder

Started by jj2007, August 24, 2012, 11:04:56 PM

Previous topic - Next topic

jj2007

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 (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

Tedd

Assuming this is what you actually want to do, have some code ;)

Potato2

jj2007

    .IF (eax == BFFM_INITIALIZED)
        invoke SendMessage, hwnd,BFFM_SETSELECTION,TRUE,lpData
    .ENDIF


Really cute trick, Tedd :t

In the meantime, I opted for GetOpenFileName, 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: