Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ITEMIDLIST/SHITEMID help needed!

158 views
Skip to first unread message

David Wilkinson

unread,
Apr 5, 2000, 3:00:00 AM4/5/00
to
Could someone please show me how to use ITEMIDLIST/SHITEMID, for example
with SHGetSpecialFolderLocation()?

TIA,

David Wilkinson


ume...@my-deja.com

unread,
Apr 5, 2000, 3:00:00 AM4/5/00
to
In article <38EB20F8...@worldnet.att.net>,

David Wilkinson <dave...@worldnet.att.net> wrote:
> Could someone please show me how to use ITEMIDLIST/SHITEMID, for
> example with SHGetSpecialFolderLocation()?

SHGetSpecialFolderLocation actually returns an ItemIdList (pidl) for the
special folder you've requested in the nFolder argument. Note that you
are responsible for freeing up the memory after use, using shell's
IMalloc interface as follows: (I've removed all the tests for success of
methods for clarity)

LPMALLOC pIMalloc;
SHGetMalloc(&pIMalloc));
LPITEMIDLIST pidlDesktop;
SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOPDIRECTORY, &pidlDesktop);

/* ... use the pidl ... */

pIMalloc->Free(pidl);
pIMalloc->Release(); /* this is a COM object */

Think of a pidl like a conventional path on steroids. Each "path"
segment is represented by a SHITEMID (starting from desktop if this
is a full pidl) and the pidl bunches up all the individual SHITEMIDs.
You can traverse the list by using the 'cb' variable of a SHITEMID to
hop to the next one in the list. You've reached the end if cb==0.


--

TSEKIT: http://personal-pages.ps.ic.ac.uk/~umeca74/


Sent via Deja.com http://www.deja.com/
Before you buy.

David Wilkinson

unread,
Apr 5, 2000, 3:00:00 AM4/5/00
to
emeca74:

Thanks for the help, but my level of confusion requires more hand-holding. I
think it's mainly the

/* ... use the pidl ... */

that I'm missing. I'm also a bit confused about where the memory for the
pidl is allocated and released, but I guess that is where the LPMALLOC comes
in.

How is one supposed to learn this from the documentation? For example

typedef struct _SHITEMID { // mkid
USHORT cb; // size of identifier, including cb itself
BYTE abID[1]; // variable length item identifier
} SHITEMID, * LPSHITEMID;
typedef const SHITEMID * LPCSHITEMID;

is not really very helpful. And for once Mike Blaszczak's book, which has a
whole chapter on Shell programming, is not really very enlightening (I have
the VC5 version, and VC5 also, BTW).

TIA,

David Wilkinson

=======================

David Lowndes

unread,
Apr 5, 2000, 3:00:00 AM4/5/00
to
>Thanks for the help, but my level of confusion requires more hand-holding. I
>think it's mainly the
>
>/* ... use the pidl ... */
>
>that I'm missing.

David,

There's a good article on PIDLs in this month's Windows Developer's
Journal (April 2000).

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.

David Wilkinson

unread,
Apr 5, 2000, 3:00:00 AM4/5/00
to
Dave:

Thanks for the info.

Is the Developers Journal worthwhile, do you think? I like to keep the number of
things I sign up for on the net to a reasonable minimum.

But actually when I looked on the CD of Mike B's book, I found that he does show
you how to do this (sorry Mike).

But really, why is this SHxxxx stuff so ferociously complicated (I don't do COM,
and I'm really not planning to, so maybe that is part of the problem). But
really.

All I wanted to do was get the user's "Personal" folder in a CString, in a way
which will work on all 32 bit platforms. Surely there must be a simpler way? Am I
supposed to look in the registry for this. If so, is this the right place:

HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal
??

Works on my 95 and NT, but is this roght on 98/2000?

David

===========================

David Lowndes

unread,
Apr 6, 2000, 3:00:00 AM4/6/00
to
>Is the Developers Journal worthwhile, do you think?

I find it's quite practically orientated - which appeals to me. I
subscribe to it - and it's an awful lot cheaper if you live in the US.

>But really, why is this SHxxxx stuff so ferociously complicated (I don't do COM,
>and I'm really not planning to, so maybe that is part of the problem).

Wish I knew <g>. I have great difficulty with COM myself. It all seems
so straight-forward and logical when you do the basics, but as soon as
you need to use it for something real, it gets really involved and
bogged down. I guess that's the price you pay for making things
general-purpose. I think COM is one of those things that gets easier
with practice. If you're anything like me, I perhaps do 1 ATL project
a year, so by the time I come round to it again, I've largely
forgotten it all.

>All I wanted to do was get the user's "Personal" folder in a CString, in a way
>which will work on all 32 bit platforms. Surely there must be a simpler way? Am I
>supposed to look in the registry for this.

I'd recommend that you stick with the API and use CSIDL_PERSONAL on
the grounds that it isolates you from any changes (however unlikely
the registry setting is to change).

>Works on my 95 and NT, but is this roght on 98/2000?

On my 2000 system that registry entry give you the personal folder, so
yes, it is consistent (for now).

David Wilkinson

unread,
Apr 6, 2000, 3:00:00 AM4/6/00
to
David:

Thanks again for the input.

David

======================================

0 new messages