Article View: borland.public.cppbuilder.nativeapi
Article #14270Re: SHGetSpecialFolderLocation!
From: Rodolfo Frino
Date: Tue, 19 Aug 2003 22:28
Date: Tue, 19 Aug 2003 22:28
68 lines
2667 bytes
2667 bytes
Probably because you didn't include the shlobj.h header file
Also modify GetPaths() as shown below
Get rid of CoTaskMemFree function since you did not allocate with neither
CoTaskMemAlloc nor CoTaskMemRealloc functions.
#define NO_WIN32_LEAN_AND_MEAN
#include <shlobj.h>
#include <vcl.h>
#pragma hdrstop
#include "SHGetSpecialFolderLocation.h"
//--------------------------------------------------------------------------
-
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//--------------------------------------------------------------------------
-
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//--------------------------------------------------------------------------
-
AnsiString GetPaths(int Folder)
{
LPITEMIDLIST List = NULL;
char Path[MAX_PATH + 1] = {0};
if (!SHGetSpecialFolderLocation(0, Folder, &List))
if (SHGetPathFromIDList(List, Path))
return String(Path);
return ""; // return an empty AnsiString in case of error
}
...
Rodolfo
"Safari" <Safari@alloymail.com> wrote in message
news:3F425543.9040507@alloymail.com...
> Hello,
> Error! Why?
> I use "ShlOBJ.hpp" & "ShellApi.hpp" but return me error!
> Error: E2451 Undefined symbol 'LPITEMIDLIST'
>
> AnsiString __fastcall GetPaths(int Folder)
> {
> LPITEMIDLIST List = NULL;
> char Path[MAX_PATH + 1] = {0};
> if (SHGetSpecialFolderLocation(0, Folder, &List) == NOERROR)
> {
> if (SHGetPathFromIDList(List, Path))
> return Path;
> CoTaskMemFree(List);
> }
> }
>
> Thanks,
> Safari
>
Technical Details
Message-ID:
<3f42a46c@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!sn-xit-09!supernews.com!newsfeed.news2me.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3F425543.9040507@alloymail.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,7ce38efab0f8f813 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-08-19 15:40:55 PST From: "Rodolfo Frino" <rodolfofrino@yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3F425543.9040507@alloymail.com> Subject: Re: SHGetSpecialFolderLocation! Date: Wed, 20 Aug 2003 08:28:25 +1000 Lines: 70 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.1165 NNTP-Posting-Host: 203.206.24.170 Message-ID: <3f42a46c@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1061332076 203.206.24.170 (19 Aug 2003 15:27:56 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!sn-xit-09!supernews.com!newsfeed.news2me.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail