#include <shlobj.hpp>
HANDLE ExtractIconByExt(AnsiString Ext)
{
SHFILEINFO FileInfo;
SHGetFileInfo(Ext.c_str(),
0,
&FileInfo,
sizeof(FileInfo),
SHGFI_USEFILEATTRIBUTES | SHGFI_ICON);
return FileInfo.hIcon;
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TIcon* icon = new TIcon;
icon->Handle = ExtractIconByExt(Edit1->Text);
Image1->Picture->Icon = icon;
delete icon;
}