function GetFileIcon( FileName: String ): HICON;
var
SHFileInfo: TSHFileInfo;
begin
ShGetFileInfo( PChar( FileName ), 0, SHFileInfo, SizeOf( TSHFileInfo ),
SHGFI_USEFILEATTRIBUTES or SHGFI_ICON or SHGFI_EXETYPE {or SHGFI_SMALLICON });
Result := SHFileInfo.hIcon;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
AIcon: TIcon;
begin
AIcon := TIcon.Create;
try
AIcon.Handle := GetFileIcon( 'C:\Program Files\Internet Explorer\iexplore.exe' );
Image1.Picture.Assign( AIcon );
finally
AIcon.Free;
end;
end;
|