Mega Code Archive

 
Categories / Delphi / Files
 

How to change an EXE files icon in runtime

Title: How to change an EXE file's icon in runtime? Question: How to change an EXE file's icon in runtime? Answer: procedure TForm1.Button1Click(Sender: TObject); var MyIcon: TIcon; FileInfo: SHFILEINFO; begin MyIcon := TIcon.Create; try SHGetFileInfo(PChar('File.exe'), 0, FileInfo, SizeOf(FileInfo), SHGFI_ICON); MyIcon.Handle := FileInfo.hIcon; DestroyIcon(FileInfo.hIcon); MyIcon.SaveToFile('Icon.ico'); Application.Icon := MyIcon; finally MyIcon.Free; end; end;