Article View: borland.public.cppbuilder.nativeapi
Article #5540Re: AccessVialoation on SHGetSpecialFolderLocation
From: George Francis
Date: Fri, 05 Aug 2005 21:57
Date: Fri, 05 Aug 2005 21:57
39 lines
2138 bytes
2138 bytes
Jonathan Benedicto wrote:
> "George Francis" <george_f@hotmail.com> wrote in message
> news:42f3d881$1@newsgroups.borland.com...
>
>>Hello, I am trying to use the following code to read the user's Send To
>>directory:
>>
>> char cBuf[MAX_PATH];
>> LPITEMIDLIST pidl;
>> SHGetSpecialFolderLocation(0, CSIDL_SENDTO, &pidl);
>> SHGetPathFromIDList(pidl, cBuf);
>>
>>It compiles OK, but I get an access violation Exception on the call to
>>SHGetSpecialFolderLocation.
>>Can anyone suggest why?
>
>
> No, but maybe you might want to use this code instead:
>
> AnsiString __fastcall GetSpecialPath(int Folder)
> {
> char Path[MAX_PATH + 1] = { 0 };
> if( ::SHGetSpecialFolderPath( NULL, Path, Folder, 0 ) )
> return AnsiString( Path );
> return "";
> }
>
> GetSpecialPath( CSIDL_SENDTO );
>
> Jonathan
>
>
Thanks but I've discovered the actual exception is being thrown from the
last line of this code:
IUnknown* Unknown = CreateComObject(CLSID_ShellLink);
IShellLink* ISLink = ((IShellLink*) Unknown );
ISLink->SetPath( _argv[0].c_str());
Technical Details
Message-ID:
<42f3e0e2$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.maxwell.syr.edu!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<42f3d881$1@newsgroups.borland.com> <42f3db7c$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,7f4466ab7adf1876 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Fri, 05 Aug 2005 17:57:56 -0400 From: George Francis <george_f@hotmail.com> User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: AccessVialoation on SHGetSpecialFolderLocation References: <42f3d881$1@newsgroups.borland.com> <42f3db7c$1@newsgroups.borland.com> In-Reply-To: <42f3db7c$1@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 209.82.52.98 Message-ID: <42f3e0e2$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1123279074 209.82.52.98 (5 Aug 2005 14:57:54 -0700) Lines: 39 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.maxwell.syr.edu!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail