How to update Res into MyProg at-runtime

delphi package - madRes, madTools, madStrings, ...
Post Reply
Mrzaa
Posts: 3
Joined: Sun Jul 31, 2005 11:02 pm

How to update Res into MyProg at-runtime

Post by Mrzaa »

help me please :(
How to Update (change, add, delete) res into myprog at runtime ?
neji
Posts: 155
Joined: Wed Mar 09, 2005 11:39 am
Contact:

Post by neji »

I don't think, that you can change youre resources at runtime. But if it's possible , look at http://help.madshi.net/madResUnit.htm
Mrzaa
Posts: 3
Joined: Sun Jul 31, 2005 11:02 pm

Post by Mrzaa »

no change in myprog res

///////////////////////
procedure DeleteFrmResource(exeFullPath, ResName: PWideChar);
var update : dword;
begin
update := BeginUpdateResourceW(exeFullPath, false);
if update <> 0 then
try
UpdateResourceW(update, PWideChar(RT_RCDATA), ResName, 0, nil, 0);
finally
EndUpdateResourceW(update, false);
end;
end;

////////////////////////////
procedure TForm1.Button1Click(Sender: TObject);
begin
deleteFrmResource(Pwidechar(exctractfilepath(application.exename)),'TFORM2');
end;
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Your own exe file is locked by Windows while it is running. As a result you can't change it. However, you could do this:

(1) Copy your.exe to your2.exe
(2) Change the resources in your2.exe
(3) Rename your.exe to your.del
(4) Rename your2.exe to your.exe
(5) Restart your program
(6) In the initialization of your program, delete your.del

However, this works only in the NT family and it needs a restart of your program.
Mrzaa
Posts: 3
Joined: Sun Jul 31, 2005 11:02 pm

How to Update (change, add, delete) res into myprog at runti

Post by Mrzaa »

Thank you :wink: !
Post Reply