| Question | |
|
How can I programatically get a file's associated default icon without looking it up in the registry and loading it explicitly? | |
| Answer | |
|
This is a lot easier than most people think. There is a relatively little-known function
called ExtractAssociatedIcon. The prototype is as follows:
Example:
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
HICON ico;
WORD idx;
ico = ExtractAssociatedIcon(HInstance,"c:WINNT\\system32\\ntimage.gif",&idx);
Image1->Picture->Icon->Handle = ico;
}
//---------------------------------------------------------------------------
|
Last Modified: 27-OCT-00