Article View: borland.public.cppbuilder.nativeapi
Article #14725Re: Localized name for My Documents
From: Martin Nijhoff
Date: Mon, 04 Aug 2003 07:43
Date: Mon, 04 Aug 2003 07:43
56 lines
2570 bytes
2570 bytes
> What does your actual code look like?
I wrote this routine to convert a PIDL to a display or path name:
AnsiString GetPathName (TItemIDList *PIDL, IShellFolder *Folder, DWORD Type)
{
TStrRet Str;
if (Folder->GetDisplayNameOf(PIDL, Type, Str) == NOERROR)
{
switch (Str.uType)
{
case STRRET_WSTR:
if (Str.pOleStr != NULL)
return(WideCharToString(Str.pOleStr));
break;
case STRRET_OFFSET:
return(((char *) PIDL) + Str.uOffset);
case STRRET_CSTR:
return(Str.cStr);
}
}
return("");
}
This is the code that gets the PIDL of the My Documents folder and displays
the different display names for it:
Ole2::IMalloc *Mem;
IShellFolder *Folder;
TItemIDList *ItemID;
if (SHGetMalloc(Mem) == NOERROR)
{
if (SHGetDesktopFolder(Folder) == NOERROR)
{
if (SHGetSpecialFolderLocation(NULL, CSIDL_PERSONAL, ItemID) ==
NOERROR)
{
Memo1->Lines->Add(GetPathName(ItemID, Folder, SHGDN_NORMAL));
Memo1->Lines->Add(GetPathName(ItemID, Folder, SHGDN_INFOLDER));
Memo1->Lines->Add(GetPathName(ItemID, Folder,
SHGDN_FORPARSING));
Mem->Free(ItemID);
}
Folder->Release();
}
Mem->Release();
}
> When you called GetDisplayNameOf(), what actual value did you pass to
> uFlags parameter? Did you use SHGDN_NORMAL, SHGDN_INFOLDER,
> or SHGDN_FORPARSING.
As you can see above, I tried all three, and they all return 'D:\Docs' on my
machine.
Technical Details
Message-ID:
<3f2e0e6d@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3f291bf5@newsgroups.borland.com> <3f2a9ab0@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,a8f8c57e6feba365 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-08-04 01:16:18 PST From: "Martin Nijhoff" <m.NOSPAMnijhoff@tba-tenNOSPAM.nl> Newsgroups: borland.public.cppbuilder.nativeapi References: <3f291bf5@newsgroups.borland.com> <3f2a9ab0@newsgroups.borland.com> Subject: Re: Localized name for My Documents Date: Mon, 4 Aug 2003 09:43:30 +0200 Lines: 58 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 NNTP-Posting-Host: 81.68.9.230 Message-ID: <3f2e0e6d@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1059982957 81.68.9.230 (4 Aug 2003 00:42:37 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail