The code below will extract the icon from the file and convert it to png, but without alpha transparency?
var IconIndex : word; icon:TIcon; png:TPngImage; bmp:TBitmap; begin IconIndex := 0; icon := TIcon.Create; icon.Handle := ExtractAssociatedIcon(hInstance,pChar(Edit1.Text), IconIndex) ; bmp:= TBitmap.Create; bmp.LoadFromFile('blank.bmp'); DrawIcon(bmp.Canvas.Handle, 0, 0, icon.Handle) ; png := TPngImage.Create(); png.Assign(bmp); png.SaveToFile('icon.png'); end;
source share