madRes - Update icon for compressed files

delphi package - madRes, madTools, madStrings, ...
Post Reply
Silver Black
Posts: 29
Joined: Fri Feb 17, 2006 11:47 am
Location: Italy

madRes - Update icon for compressed files

Post by Silver Black »

I used your unit to change icon of executable files: it just worked perfectly!

But now I want to modify the icon of compressed (UPX) files. It works, but the files cannot be executed, an AV error is being raised. And, more strange, if I change the icon to the uncompressed file and only THEN i use UPX on that file, tha icon is lost at first refresh (F5) but the file is executed normally without errors.

Here is my code:

Code: Select all

    dwH := BeginUpdateResourceW(PWideChar(WideString(Self.labedtSourceFile.Text)), False);
    try
      if LoadIconGroupResourceW(dwH, RESOURCE_MAIN_ICON, 0, PWideChar(WideString(Self.labedtIconFile.Text))) then
        Application.MessageBox('OK!!!', PChar(Application.Title), 0)
      else
        Application.MessageBox('Error', PChar(Application.Title), 0)
    finally
      EndUpdateResourceW(dwH, False);
    end;
Is is possible to change resources of compressed files?
How can you explain the second behaviour? (do I use the wrong code?)

Thanks in advance!
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

After you ran UPX, the resource section has an invalid format. That's why you run into trouble when using madRes at that time. You'll experience similar problems when using resource editors like e.g. "ResourceHacker".

The 2nd problem is strange. Right now I don't know why that happens. Does that occur with any executable file or just with one specific?
Silver Black
Posts: 29
Joined: Fri Feb 17, 2006 11:47 am
Location: Italy

Post by Silver Black »

Unfortunately it occours with ANY file I tried with... :(
Post Reply