Article View: borland.public.cppbuilder.nativeapi
Article #1847Re: Getting the location of My Documents
From: Remy Lebeau (TeamB)
Date: Fri, 25 May 2007 18:55
Date: Fri, 25 May 2007 18:55
33 lines
1881 bytes
1881 bytes
"JB" <jo4508@yahoo.co.uk> wrote in message
news:46571711@newsgroups.borland.com...
> if (SHGetFolderLocation(NULL, CSIDL_MYDOCUMENTS
CLSID_MYDOCUMENT is only recognized on XP and higher. It is
equivilent to CLSID_PERSONAL, which is recognized on all versions.
> != S_FALSE
That is the wrong way to check for errors. Anything other than S_OK is
an error. You should use the SUCCEEDED() macro instead:
AnsiString Pathname;
LPITEMIDLIST pidlDocFiles = NULL;
HRESULT hRes = SHGetFolderLocation(NULL, CSIDL_MYDOCUMENTS, NULL,
0, &pidlDocFiles);
if( FAILED(hRes) )
hRes = SHGetFolderLocation(NULL, CSIDL_PERSONAL, NULL, 0,
&pidlDocFiles);
if( SUCCEEDED(hRes) )
{
char Buf[MAX_PATH+1] = {0};
SHGetPathFromIDList(pidlDocFiles, Buf);
CoTaskMemFree(pidlDocFiles);
Pathname = Buf;
}
Gambit
Technical Details
Message-ID:
<4657317a$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<4656efa1$1@newsgroups.borland.com> <46571424@newsgroups.borland.com> <46571711@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,9503052ea4e0798c X-Google-Attributes: gid10cc67,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <4656efa1$1@newsgroups.borland.com> <46571424@newsgroups.borland.com> <46571711@newsgroups.borland.com> Subject: Re: Getting the location of My Documents Date: Fri, 25 May 2007 11:55:52 -0700 Lines: 35 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 75.82.251.205 Message-ID: <4657317a$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1180119418 75.82.251.205 (25 May 2007 11:56:58 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail