🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Finding the name of the Program Files directory

#11932
From: Mark Taylor
Date: Wed, 07 Jan 2004 15:53
61 lines
2959 bytes
Hi Fernando -

Check out this site for the SHGetSpecialFolderPath Function:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shgetspecialfolderpath.asp

and for the CSIDL parameter:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/enums/csidl.asp


Now, as far as your compiler error, I've run into this one a few times.  Hopefully this site will be of some help:

http://www.bcbdev.com/faqs/faq91.htm

Hope this helps-

Mark





>I couldn't find that function, but did find SHGetSpecilaFolderLocation().
>However, when I try to include shlobj.h in order to use it, I get a compiler
>error.
>[C++ Error] shobjidl.h(2193): E2238 Multiple declaration for 'FOLDERSETTINGS'
>[C++ Error] shobjidl.h(8095): E2238 Multiple declaration for 'DESKBANDINFO'
>[C++ Error] shlobj.h(1422): E2238 Multiple declaration for 'FVSHOWINFO'
>[C++ Error] shlobj.h(3457): E2238 Multiple declaration for 'SHELLFLAGSTATE'
>
>This is the code:
>---------------------------------------------------------------------
>#include <vcl.h>
>#include <windows.h>
>#include <shlobj.h>
>#pragma hdrstop
>#include "Unit1.h"
>//---------------------------------------------------------------------------
>#pragma package(smart_init)
>
>
>AnsiString GetSpecialFolderPath(int nFolder)
>{
>AnsiString retPath;
>char szPath[_MAX_PATH];
>LPITEMIDLIST pidl;
> HRESULT hr = SHGetSpecialFolderLocation(NULL, nFolder, &pidl);
> if (hr==NOERROR && SHGetPathFromIDList(pidl, szPath))
>  retPath=szPath;
> // Allocate a pointer to an IMalloc interface
> LPMALLOC pMalloc;
> // Get the address of our task allocator's IMalloc interface
> hr = SHGetMalloc(&pMalloc);
> // Free the item ID list allocated by SHGetSpecialFolderLocation
> pMalloc->Free(pidl);
> // Free our task allocator
> pMalloc->Release();
>return retPath;
>} 
Technical Details
Message-ID: <3ffc3980$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <8rtnvvs0ekdahr4ti11p9tbhpvvek5taju@4ax.com> <3ffc198e$1@newsgroups.borland.com> <o5bovvo2ruigqkkvpvh35h8p4g7479hm54@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,8234f234f0df84a1
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-01-07 09:10:28 PST
From: "Mark Taylor" <mark_taylorNOSPAM@mindspringNOSPAM.comNOSPAM>
Sender: "Mark Taylor" <mark_taylorNOSPAM@mindspringNOSPAM.comNOSPAM>
Reply-To: "Mark Taylor" <mark_taylorNOSPAM@mindspringNOSPAM.comNOSPAM>
Subject: Re: Finding the name of the Program Files directory
Newsgroups: borland.public.cppbuilder.nativeapi
X-User-Info: 208.61.191.68     
References: <8rtnvvs0ekdahr4ti11p9tbhpvvek5taju@4ax.com> <3ffc198e$1@newsgroups.borland.com> <o5bovvo2ruigqkkvpvh35h8p4g7479hm54@4ax.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <3ffc3980$1@newsgroups.borland.com>
Date: 7 Jan 2004 08:53:20 -0700
X-Trace: newsgroups.borland.com 1073494400 207.105.83.66 (7 Jan 2004 08:53:20 -0700)
Lines: 62
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail