🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #12003

Re: Retrieves information about the file system

#12003
From: Bob Gonder
Date: Sun, 04 Jan 2004 18:29
24 lines
1889 bytes
Daniele Pellone wrote:

>When I use the command "SHGetFileInfo", I receive the error
>"ERROR_NOT_ENOUGH_MEMORY", but the icon is however returned.

>  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?

The Help makes no mention of GetLastError(), therefore, you probably
shouldn't rely on it containing anything meaningful.
Instead, check the return value:
DWORD ret = SHGetFileInfo(........);
	if( ret == 0 )  HandleYourError();

Also, make sure you release the Icon when you are done with it....
From MSDN:
"If SHGetFileInfo returns an icon handle in the hIcon member of the
SHFILEINFO structure pointed to by psfi, you are responsible for
freeing it with DestroyIcon when you no longer need it."
Technical Details
Message-ID: <lhmgvv0d9pgt82ci3qlvjjtod21e0mpnmv@4ax.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <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 10:39:44 PST
From: Bob Gonder <notbg@notmindspring.invalid>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Retrieves information about the file system
Date: Sun, 04 Jan 2004 10:29:26 -0800
Organization: MindSpring Enterprises, Inc.
Reply-To: notbg@notmindspring.invalid
Message-ID: <lhmgvv0d9pgt82ci3qlvjjtod21e0mpnmv@4ax.com>
References: <3ff806ec@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 67.31.165.203
X-Trace: newsgroups.borland.com 1073240969 67.31.165.203 (4 Jan 2004 10:29:29 -0700)
Lines: 27
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail