Article View: borland.public.cppbuilder.nativeapi
Article #831Re: Get the icon by using "SHGetFileInfo"...
From: Asger Joergensen
Date: Sun, 02 Dec 2007 19:33
Date: Sun, 02 Dec 2007 19:33
45 lines
2057 bytes
2057 bytes
Hi remmurds
remmurds says:
> Thank you for your response :)
>
> I try to use this function to get the icon:
>
>
> SHGetFileInfo(FileName.c_str(), 0, &info, sizeof(info), SHGFI_LARGEICON |
> SHGFI_SYSICONINDEX);
> DrawIconEx(ImageIco->Canvas->Handle, 0, 0, info.hIcon, 48, 48, 0, 0,
> DI_NORMAL | DI_COMPAT);
>
>
> But it doesn't work.
> Do I use it with incorrect parameters?
Do You check if the the handle is different from NULL ?
According to the helpfile SHGFI_ICON is the one
that will retrieve the handle to the icon the other
SHGFI_LARGEICON go for a specific size and You don't
need the index.
This would be my suggestion:
DWORD Res = SHGetFileInfo(FileName.c_str(), 0, &info, sizeof(info), SHGFI_ICON);
if( ! Res){// GetLastError}
if(info.hIcon)
{
if( ! DrawIconEx(ImageIco->Canvas->Handle, 0, 0, info.hIcon, 48, 48, 0, 0,
DI_NORMAL) )
{// GetLastError}
}
by the way what is ImageIco ?
is it a TImage ?
Have You remembered to set the size of ImageIco ?
Kind regards
Asger
Technical Details
Message-ID:
<MPG.21bd27055e96426f989930@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!club-internet.fr!feedme-small.clubint.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4751fbc8$1@newsgroups.borland.com> <MPG.21bd0b1963f2bda698992f@newsgroups.borland.com> <4752fc27$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,bee658860984a9b7 X-Google-Attributes: gid10cc67,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: Asger Joergensen <junk@Asger-P.dk> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Get the icon by using "SHGetFileInfo"... Date: Sun, 2 Dec 2007 20:33:42 +0100 Message-ID: <MPG.21bd27055e96426f989930@newsgroups.borland.com> References: <4751fbc8$1@newsgroups.borland.com> <MPG.21bd0b1963f2bda698992f@newsgroups.borland.com> <4752fc27$1@newsgroups.borland.com> Organization: Asger-P MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit User-Agent: MicroPlanet-Gravity/2.70.2067 NNTP-Posting-Host: 83.73.201.25 X-Trace: newsgroups.borland.com 1196624017 83.73.201.25 (2 Dec 2007 11:33:37 -0700) Lines: 45 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!club-internet.fr!feedme-small.clubint.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail