Hi
This is not strictly an ImageEN issue but I can't find anyone who has cracked it after extensive searching of the internet about it.
I want to capture the ICON of an application.
I can do this by calling SHGetFileInfo, and then converting the returned ICO into a BMP.
This works fine, but I lose the transparency.
How can I do it and save it as a regular ICON?
Bruce.
function TfmMain.GetApplicationICON(path: string): TIcon;
var
Icon : TIcon;
FileInfo : SHFILEINFO;
begin
Icon:=TIcon.Create;
try
//Get the DisplayName
SHGetFileInfo(PChar(path),0,FileInfo,SizeOf(FileInfo),SHGFI_DISPLAYNAME);
// Get the TypeName
SHGetFileInfo(PChar(path),0,FileInfo,SizeOf(FileInfo),SHGFI_TYPENAME);
// Get the applicatiion ICON
SHGetFileInfo(PChar(path),0,FileInfo,SizeOf(FileInfo),SHGFI_ICON or SHGFI_LARGEICON);
Icon.Handle:=FileInfo.hIcon;
result:=Icon;
//result:=TBitMap.Create;
//result.Height:=Icon.Height;
//result.Width:=Icon.Width;
//result.Canvas.Draw(0,0,Icon);
DestroyIcon(FileInfo.hIcon);
finally
Icon.Free;
end;
end;