Article View: borland.public.cppbuilder.nativeapi
Article #15446Re: What is the Correct way to get a special folder location?
From: Remy Lebeau (TeamB)
Date: Sat, 28 Jun 2003 03:44
Date: Sat, 28 Jun 2003 03:44
59 lines
3219 bytes
3219 bytes
"Zack" <a@bv.com> wrote in message news:3efcf824@newsgroups.borland.com...
> I have been using SHGetSpecialFolderPath() to
> get folders like the System, Windows, Fonts etc.
You could just use GetWindowsDirectory() or GetSystemDirectory() instead.
There is no pre-made function for the Fonts folder specifically, though you
can use GetWindowsDirectory() first and then append "Fonts" to it.
> However, this creates a dependency ... to Shell32.dll.
Correct, since SHGetSpecialFolderLocation(), SHGetSpecialFolderPath(), and
any other SH...() function in general are Shell-related functions, thus you
need to use the shell's DLL in order to use them.
> Further this function was not implimented
> until after version 4.71 of shell32.dll.
SHELL32.DLL v4.71+ is available on any system that has IE4+ installed.
Win98/ME and Win2K/XP all ship with that version or higher. The only OSs
you need to worry about are Win95 and NT4, and more times than not users
will have IE4 installed on them as well.
If this is not suitable enough for you, then use
SHGetSpecialFolderLocation() and SHGetPathFromIDList() instead. These
functions are included in SHELL32.DLL v4.0, which is included in Win95 and
WinNT4 as well. SHGetSpecialFolderPath() is simply a higher-level wrapper
that combines the same functionality internally which they perform
separately.
So, for example, if you had the following code previously:
char buffer[MAX_PATH+1] = {0};
if( SHGetSpecialFolderPath(Handle, buffer, CSIDL_FONTS, FALSE) )
// use buffer as needed
Then you can do this instead:
char buffer[MAX_PATH+1] = {0};
LPITEMIDLIST pidl = NULL;
if( SUCCEEDED(SHGetSpecialFolderLocation(Handle, CSIDL_FONTS, &pidl)) )
{
if( SHGetPathFromIDList(pidl, buffer) )
// use buffer as needed
CoTaskMemFree(pidl);
}
> Now - users on NT4 and 95 are out of luck because no
> matter what they do - they cannot update this system file
> to a version beyond 4.0 and thus can never register my
> COM server and use my software.
Of course they can. They just need to install IE4+, that's all. It updates
SHELL32.DLL as part of its installation.
Gambit
Technical Details
Message-ID:
<3efd0e2c$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-04!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3efcf824@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,780217d415786dcd X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-06-27 20:52:31 PST From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3efcf824@newsgroups.borland.com> Subject: Re: What is the Correct way to get a special folder location? Date: Fri, 27 Jun 2003 20:44:50 -0700 Lines: 61 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 207.175.226.26 Message-ID: <3efd0e2c$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1056771628 207.175.226.26 (27 Jun 2003 20:40:28 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-04!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail