From: Eucloid on
Hi!

My endeavor is when launching my application, to select the last
accessed folder of TreeView structure that was populated by the
lpsfDesktop->EnumObjects(lpsfDesktop). When the tree is first
initialized, it contains only My Computer, My Document, Network, and
Recycle Bin. I'm basing my implementation on (Barretto VN 7/2002)
project on koders.com.

So what I tried to do is use ParseDisplayName() on the folder I want
to navigate too in order to retrieve the PIDL. Then use
SHBindToParent() function to get the parent's LPSHELLFOLDER pointer.
But then I cannot get that folder PIDL to repeat the steps until
reaching root. For example:

[code]
// szOleChar contains "C:\\Documents and Settings\\Eucloid\\My
Documents\\";
hr = lpsfDeskTop->lpVtbl->ParseDisplayName(lpsfDeskTop, NULL, NULL,
szOleChar, &chEaten, &pidl, &dwAttributes);
// convert PIDL to LPSHELLFOLDER
LPSHELLFOLDER psfFolder = NULL;
hr = SHBindToParentLocal(pidl, &IID_IShellFolder, &psfFolder,
&pidlLast);
// Then how do I get the psfFolder's pidl? With the pidl, I could bind
again to the Parent folder.
[/code]

(ii) Is this the right way to do that? I also don't know how to match
the "My Document" to "C:\\Documents and Settings\\Eucloid\\My Documents
\\"; I tried IShellFolder->CompareIDs(), and ILIsParent() without
success. I really don't know why ILIsParent doesn't work. That would
have been a solution to what I want to do.

Thanks. And I'll post the answer if I ever find it.
Francois
From: jon on
I'm not 100% sure what you want to do, but what I _think_ you want to
do is walk the folder tree in reverse.

If you want to get the parent of a PIDL, as a PIDL, you don't need to
bind to the folder first - just chop off the last SHITEMID in the PIDL
(the equivalent for a string path is removing the last component of
the path). The ILRemoveLastID function can do that for you.

Apologies if that's not what you're asking - maybe you could give a
more detailed example of what you're hoping to achieve.

Cheers,
Jon

On 13 July, 12:03, Eucloid <eucl...(a)gmail.com> wrote:
> Hi!
>
> My endeavor is when launching my application, to select the last
> accessed folder of TreeView structure that was populated by the
> lpsfDesktop->EnumObjects(lpsfDesktop). When the tree is first
> initialized, it contains only My Computer, My Document, Network, and
> Recycle Bin. I'm basing my implementation on (Barretto VN 7/2002)
> project on koders.com.
>
> So what I tried to do is use ParseDisplayName() on the folder I want
> to navigate too in order to retrieve the PIDL. Then use
> SHBindToParent() function to get the parent's LPSHELLFOLDER pointer.
> But then I cannot get that folder PIDL to repeat the steps until
> reaching root. For example:
>
> [code]
> // szOleChar contains "C:\\Documents and Settings\\Eucloid\\My
> Documents\\";
> hr = lpsfDeskTop->lpVtbl->ParseDisplayName(lpsfDeskTop, NULL, NULL,
> szOleChar, &chEaten, &pidl, &dwAttributes);
> // convert PIDL to LPSHELLFOLDER
> LPSHELLFOLDER psfFolder = NULL;
> hr = SHBindToParentLocal(pidl, &IID_IShellFolder, &psfFolder,
> &pidlLast);
> // Then how do I get the psfFolder's pidl? With the pidl, I could bind
> again to the Parent folder.
> [/code]
>
> (ii) Is this the right way to do that? I also don't know how to match
> the "My Document" to "C:\\Documents and Settings\\Eucloid\\My Documents
> \\"; I tried IShellFolder->CompareIDs(), and ILIsParent() without
> success. I really don't know why ILIsParent doesn't work. That would
> have been a solution to what I want to do.
>
> Thanks. And I'll post the answer if I ever find it.
> Francois

From: Eucloid on
Yeah this is exactly what I wanted to do : walk the folder tree in
reverse. Thanks!
I'm going to try it when I get back home after work.

Francois


On Jul 12, 10:51 pm, jon <jpot...(a)gmail.com> wrote:
> I'm not 100% sure what you want to do, but what I _think_ you want to
> do is walk the folder tree in reverse.
>
> If you want to get the parent of a PIDL, as a PIDL, you don't need to
> bind to the folder first - just chop off the last SHITEMID in the PIDL
> (the equivalent for a string path is removing the last component of
> the path). The ILRemoveLastID function can do that for you.
>
> Apologies if that's not what you're asking - maybe you could give a
> more detailed example of what you're hoping to achieve.
>
> Cheers,
> Jon
>