Change icon of my app in runtime
-
- Posts: 4
- Joined: Sat Jul 08, 2023 1:57 pm
Change icon of my app in runtime
Hi all!
Is possible using mad api change the icon of my app in the runtime?
Is possible using mad api change the icon of my app in the runtime?
Re: Change icon of my app in runtime
Do you mean you want Windows to change the icon that is shown in the top left corner of your main form, without changing anything on harddisk?
Or do you mean you want to modify your own EXE file on harddisk to replace the icon?
Or do you mean you want to modify your own EXE file on harddisk to replace the icon?
-
- Posts: 4
- Joined: Sat Jul 08, 2023 1:57 pm
Re: Change icon of my app in runtime
Hi madshi,
Thanks for your reply!
I want to modify my own EXE file on harddisk to replace the icon. But my app is running Or using another app to replace the icon.
Thanks for your reply!
I want to modify my own EXE file on harddisk to replace the icon. But my app is running Or using another app to replace the icon.
Re: Change icon of my app in runtime
You can't do that while your EXE is running. It's locked for write-access in that moment. What you probably could do is rename your running EXE file (Project1.exe -> Project1old.exe), then copy it to the old name (Project1old.exe -> Project1.exe). Windows usually allows that, and the running EXE is then Project1old.exe, and then it will be able to modify Project1.exe.
You can use the APIs in "madRes" to change the icon.
You can use the APIs in "madRes" to change the icon.
-
- Posts: 4
- Joined: Sat Jul 08, 2023 1:57 pm
Re: Change icon of my app in runtime
Hi!
Do you have any simples sample to show me?
Do you have any simples sample to show me?
Re: Change icon of my app in runtime
No, sorry. But ChatGPT is your friend. Maybe it will even write the code for you.
-
- Posts: 4
- Joined: Sat Jul 08, 2023 1:57 pm
Re: Change icon of my app in runtime
Hi again!
ChatGPT wrote this:
Where can I found the class:
TCustomResUpdater ?
ChatGPT wrote this:
Code: Select all
uses
MADRes;
procedure ChangeExeIcon(const FileName, IconPath: string);
var
Icon: TIcon;
ResUpdater: TCustomResUpdater;
begin
Icon := TIcon.Create;
try
Icon.LoadFromFile(IconPath);
ResUpdater := TCustomResUpdater.Create(FileName);
try
if ResUpdater.UpdateIcon(Icon) then
ShowMessage('updated icon')
else
ShowMessage('Error');
finally
ResUpdater.Free;
end;
finally
Icon.Free;
end;
end;
TCustomResUpdater ?
Re: Change icon of my app in runtime
I don't know, probably ChatGPT lied, as usual...