🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #8826

Re: SHGetSpecialFolderLocation, Different results on WinXP and Win98

#8826
From: Eelke
Date: Tue, 21 Sep 2004 12:50
83 lines
3202 bytes
Jaepil Kim wrote:
> Hi i have following piece of code.
> 
> When i do:
> GetSpecialFolderLocation(Application->Handle, CSIDL_DESKTOP, true)
> 
> On WinXP i get "C:\Documents and settings\Me\Desktop"
> but on Win98 i get "Desktop"
They should be different, however for Win98 I would have expected:

c:\windows\desktop
> 
> What am i doing wrong?
> 
> 
> //-------------------------------------------------------------
> 
> AnsiString GetSpecialFolderLocation(HANDLE AHandle, int SpecialFolder, 
> bool ForParsing)
> {
>   // Local variables
>   PItemIDList l_DesktopPIDL;
>   TStrRet StrRet;
>   PChar  P;
>   int Flags;
>   AnsiString * Result;
>   LPSHELLFOLDER IDesktopFolder;
>   bool l_FoundRequested;
> 
>   // GetDesktop's ItemIDList
>   try {
>     OleCheck(SHGetSpecialFolderLocation(AHandle, SpecialFolder, 
> &l_DesktopPIDL));
>     l_FoundRequested = true;
>   } catch (...) {
>     l_FoundRequested = false;
>   }
> 
>   if (l_FoundRequested == false) {
>     OleCheck(SHGetSpecialFolderLocation(AHandle, CSIDL_DESKTOP, 
> &l_DesktopPIDL));
>   }
> 
>   OleCheck(SHGetDesktopFolder(&IDesktopFolder));
> 
>   if (ForParsing) {
>     Flags = SHGDN_FORPARSING;
>   } else {
>     Flags = SHGDN_NORMAL;
>   }
> 
>   IDesktopFolder->GetDisplayNameOf(l_DesktopPIDL, Flags, &StrRet);
> 
>   switch (StrRet.uType)
>   {
>     case STRRET_CSTR:
>       Result = new AnsiString(StrRet.cStr, strlen(StrRet.cStr));
>       break;
>     case STRRET_OFFSET:
>       P = &l_DesktopPIDL->mkid.abID[StrRet.uOffset - 
> sizeof(l_DesktopPIDL->mkid.cb)];
>       Result = new AnsiString(P);
>       break;
>     case STRRET_WSTR:
>       Result = new AnsiString(StrRet.pOleStr);
>       break;
>   }
> 
>   IDesktopFolder->Release();
> 
>   return (*Result);
> }
> //-------------------------------------------------------------
> 
> Programer - SplashMedia
> http://splashmedia.co.nz

It probably would be easier to use SHGetSpecialFolderPath or 
SHGetFolderPath as it returns a normal path. Notice that SHGetFolderPath 
requires you to distribute an additional DLL (ShFolder.dll) with your 
app for Windows 9x machines.

Eelke
Technical Details
Message-ID: <415023a0$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news1.google.com!news.glorb.com!news.zanker.org!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <414fd5ab$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,b6d56e8c83c28a24
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Tue, 21 Sep 2004 14:50:48 +0200
From: Eelke <e.klein@mplussoftware.nl>
User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: SHGetSpecialFolderLocation, Different results on WinXP and Win98
References: <414fd5ab$1@newsgroups.borland.com>
In-Reply-To: <414fd5ab$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 81.58.1.162
Message-ID: <415023a0$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1095771040 81.58.1.162 (21 Sep 2004 05:50:40 -0700)
Lines: 83
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news1.google.com!news.glorb.com!news.zanker.org!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail