Board index » cppbuilder » getting the icon associated with a certain file type

getting the icon associated with a certain file type

How do I retrieve the icon associated with a certain file type, for example
*.txt?  I'm using Borland C++ Builder 4
 

Re:getting the icon associated with a certain file type


Quote
Paul wrote:
> How do I retrieve the icon associated with a certain file type, for example
> *.txt?  I'm using Borland C++ Builder 4

Here is one way, but you need a valid filename.

#include <shellapi.h>

// use SHGFI_ICON |SHGFI_SMALLICON for small icon
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  SHFILEINFO psfi;

  SHGetFileInfo("c:\\perform.log",
                NULL,
                &psfi,
                sizeof(psfi),
                SHGFI_ICON);
  Image1->Picture->Icon->Handle = psfi.hIcon;

Quote
}

Look in win32.hlp for SHGetFileInfo, it can give you more info than just the
icon.

Re:getting the icon associated with a certain file type


I have a free component called TRegExtension at
http://reg.lebeausoftware.org
One of it's properties returns the filename of the icon assocated with a
given file extension.

Gambit

Quote
"Paul" <yt...@usa.net> wrote in message news:3bdc267d_2@dnews...
> How do I retrieve the icon associated with a certain file type, for
example
> *.txt?  I'm using Borland C++ Builder 4

Other Threads