Article View: borland.public.cppbuilder.nativeapi
Article #12004Re: Retrieves information about the file system
From: Rodolfo Frino - Macrosoft
Date: Mon, 05 Jan 2004 05:52
Date: Mon, 05 Jan 2004 05:52
50 lines
2357 bytes
2357 bytes
Your example did not produce an error. Do not use getlasterror() like that
with this API.
It will not produce the results you expect. Instead check for the return
value of the function
If the return value is 0, then SHGetFileInfo has failed.
As an example put an inexistant path such as "c:\\skjijoiiudbasjduafod".
SHGetFileInfo
will then return 0, and you can catch this error simply with an if
statement:
SHFILEINFO FileInfo;
unsigned long h = SHGetFileInfo("c:\\skjijoiiudbasjduafod",
0, &FileInfo,
sizeof(FileInfo), SHGFI_ICON);
// Correct way of detecting an error
if (!h)
ShowMessage("SHGetFileInfo Error");
else
ShowMessage("handle = " + String(h));
Rodolfo
"Daniele Pellone" <pellone@tiscali.it> wrote in message
news:3ff806ec@newsgroups.borland.com...
> Hi at all !!!
>
> When I use the command "SHGetFileInfo", I receive the error
> "ERROR_NOT_ENOUGH_MEMORY", but the icon is however returned.
> Here my code:
>
> void __fastcall TForm1::Button1Click(TObject *Sender)
> {
> SHFILEINFO FileInfo;
>
>
SHGetFileInfo("c:\\windows\\win.ini",0,&FileInfo,sizeof(FileInfo),SHGFI_ICON
> );
> ShowMessage(GetLastError());
> Image1->Picture->Icon->Handle=FileInfo.hIcon;
> }
>
> Could anybody explain me the correct use of SHGetFileInfo?
> Thanks in advance.
>
>
Technical Details
Message-ID:
<3ff8fb74@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3ff806ec@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,1d988a36ee413979 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-01-04 22:09:22 PST From: "Rodolfo Frino - Macrosoft" <Microhaven@Atlantis.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3ff806ec@newsgroups.borland.com> Subject: Re: Retrieves information about the file system Date: Mon, 5 Jan 2004 16:52:24 +1100 Lines: 52 Organization: Microhaven 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.17.234 Message-ID: <3ff8fb74@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1073281908 203.206.17.234 (4 Jan 2004 21:51:48 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail