How can I get the PIDL of the current folder if I have it's path. I had thought that SHGetFolderLocation would do the trick but that is only for system folders, I can't seem to find a command that will retrieve the PIDL of the current folder. I am trying to implement the SHBrowseForFolder function but want to begin at the current folder and browse in both directions...

LOCAL	szFolderName[MAX_PATH]	:BYTE

LOCAL iImage :DWORD
LOCAL lpbi :BROWSEINFO

invoke GetCurrentDirectory,MAX_PATH,ADDR szFolderName

; Need to convert szFolderName to a PIDL for use in BROWSEINFO

mov eax,hDlg
mov lpbi.hwndOwner,eax
mov lpbi.pidlRoot,NULL
lea eax,szFolderName
mov lpbi.pszDisplayName,eax
mov lpbi.ulFlags,BIF_RETURNONLYFSDIRS
mov lpbi.lpfn,NULL
mov lpbi.lParam,NULL
lea eax,iImage
mov lpbi.iImage,eax

invoke SHBrowseForFolder,ADDR lpbi
mov edx,eax ; eax is overwritten by the SHGetPathFromIDList invoke so switch registers
invoke SHGetPathFromIDList,edx,ADDR szFolderName
Posted on 2003-04-20 16:50:45 by donkey
Does anybody have the correct order for the IShellFolder interface ? MSDN just lists the fields in alpha order as usual and I don't have the C++ header files to check the proper order. If someone could check the shobjidl.h file and post the structure that I need it would probably solve my problem, I need to know the correct order for the following :
ShellFolder Struct

; IUnKnown
QueryInterface DWORD ?
AddRef DWORD ?
Release DWORD ?
; IShellFolder
BindToObject DWORD ?
BindToStorage DWORD ?
CompareIDs DWORD ?
CreateViewObject DWORD ?
EnumObjects DWORD ?
GetAttributesOf DWORD ?
GetDisplayNameOf DWORD ?
GetUIObjectOf DWORD ?
ParseDisplayName DWORD ?
SetNameOf DWORD ?
ShellFolder ends
Bah, found it for those who are interested it's
ShellFolder STRUCT

; IUnknown
QueryInterface DWORD ?
AddRef DWORD ?
Release DWORD ?
; IShellFolder
ParseDisplayName DWORD ?
EnumObjects DWORD ?
BindToObject DWORD ?
BindToStorage DWORD ?
CompareIDs DWORD ?
CreateViewObject DWORD ?
GetAttributesOf DWORD ?
GetUIObjectOf DWORD ?
GetDisplayNameOf DWORD ?
SetNameOf DWORD ?
ShellFolder ends
I don't know why MS just can't put these things in the proper order in MSDN, it would make life alot easier :rolleyes:
Posted on 2003-04-20 18:25:29 by donkey

I don't know why MS just can't put these things in the proper order in MSDN, it would make life alot easier :rolleyes:


Not everyone codes in assembly. :)
Posted on 2003-04-20 20:09:03 by comrade



Not everyone codes in assembly. :)

The order of the structure is the same in any language, they just assume that you are using their header file :)
Posted on 2003-04-20 20:29:41 by donkey
Hi donkey,

to get a fully qualified PIDL of a folder from a path do:

1. get desktop folder object with SHGetDesktopFolder
2. call method ParseDisplayName with the path you want to translate

Japheth
Posted on 2003-04-21 02:59:32 by japheth
Thanks japheth,

That's about what I had in mind, I'm just trying to figure out the details of it now. I was having trouble with IShellFolder but I got the right order, now it's just to be able to make the call. I really dislike COM :mad:
Posted on 2003-04-21 03:08:08 by donkey
Darn, well I figured it out but it was all for nothing. You can't browse above the PIDL that you specify as the starting point so it makes it pretty useless for my purposes. If you're interested in getting the PIDL for the current folder here is my solution to the problem :
IShellFolder STRUCT

; IUnknown
QueryInterface DWORD ?
AddRef DWORD ?
Release DWORD ?
; IShellFolder
ParseDisplayName DWORD ?
EnumObjects DWORD ?
BindToObject DWORD ?
BindToStorage DWORD ?
CompareIDs DWORD ?
CreateViewObject DWORD ?
GetAttributesOf DWORD ?
GetUIObjectOf DWORD ?
GetDisplayNameOf DWORD ?
SetNameOf DWORD ?
IShellFolder ends

GetCurrentPIDL proc
LOCAL pShellFolder :DWORD
LOCAL szFolder[MAX_PATH] :WORD
LOCAL Attribs :DWORD
LOCAL Pidl[32] :DWORD
LOCAL Eaten :DWORD

invoke CoInitialize,NULL

invoke GetCurrentDirectoryW,MAX_PATH,ADDR szFolder
invoke SHGetDesktopFolder,ADDR pShellFolder

lea eax,Attribs
push eax
lea eax,Pidl
push eax
lea eax,Eaten
push eax
lea eax,szFolder
push eax
push NULL
push hDlg
push pShellFolder
mov edi,pShellFolder
mov edi,[edi]
call [edi].IShellFolder.ParseDisplayName

push pShellFolder
mov edi,pShellFolder
mov edi,[edi]
call [edi].IShellFolder.Release

invoke CoUninitialize
mov eax,Pidl
ret

GetCurrentPIDL endp
Posted on 2003-04-21 04:32:13 by donkey
Possibly this may work (no need for COM):



mov eax, hWnd
mov bi.hwndOwner, eax
....
mov bi.lpfn, offset browsecallback
invoke SHBrowseForFolder, addr bi


and:

browsecallback proc hWnd:HWND, msg:DWORD, lParam:LPARAM, lpData:LPARAM
.if (msg == BFFM_INITIALIZED)
invoke SendMessage, hWnd, BFFM_SETSELECTION, TRUE, CStr("c:\temp")
.endif
return 0
browsecallback endp
Posted on 2003-04-21 05:09:49 by japheth
donkey,
if you still want that header file, PM me your email address and i will send it to you (it is 250KB, i don't wanna attach it here).
Posted on 2003-04-21 07:00:37 by sluggy
Thanks japheth,

Works fine, I really should have checked that first, would have saved me a minor migrain. Oh well, I may find a use for the PIDL thing somewhere.

Thanks Sluggy,

I tried to PM you but your box was full. I got the files off the net (that's how I found the right struct order). It was a nice offer anyway :)
Posted on 2003-04-21 11:37:27 by donkey
Well, I thought of a great use for my PIDL thing, I use the PIDL of the file for the lParam in the treeview of my program, no more linked list for paths. The proc has been modified a bit and I put it in Algorithms and Source Code where more people will see it. :)

http://www.asmcommunity.net/board/index.php?topic=12729
Posted on 2003-04-21 13:32:04 by donkey