I've been trying to help somebody on EE to use madRes to change the icon from an exe. the following code works fine if the icon group is something text, but if it's a number, then the icon group is duplicated.
bogus, input, app
Code: Select all
program Project1;
{$R *.res}
{$R icons.res}
begin
end.
Code: Select all
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
128 ICON "green.ico"
TEST ICON "green.ico"
Code: Select all
program Project2;
uses
windows, madres;
{$R *.res}
function MAKELANGID(sPrimaryLanguage : Word;
sSubLanguage : Word) : Word;
begin
result := (sSubLanguage shl 10) or
sPrimaryLanguage;
end;
function UpdateExeIcon(exeFile, iconGroup, icoFile: string; language: word) : boolean;
var resUpdateHandle : dword;
begin
resUpdateHandle := BeginUpdateResourceW(PWideChar(wideString(exeFile)), false);
if resUpdateHandle <> 0 then begin
result := LoadIconGroupResourceW(resUpdateHandle, PWideChar(wideString(iconGroup)), language, PWideChar(wideString(icoFile)));
result := EndUpdateResourceW(resUpdateHandle, false) and result;
end else
result := false;
end;
begin
UpdateExeIcon('test.exe', '128', 'red.ico', makelangid(LANG_ENGLISH,SUBLANG_ENGLISH_US));
end.
UpdateExeIcon('test.exe', 'TEST', 'red.ico', makelangid(LANG_ENGLISH,SUBLANG_ENGLISH_US));
then the icon changes from green to red: no problems. but if you use it with '128', then the problem is reproducing.
using // madRes.pas version: 1.0j · date: 2005-07-15
any ideas?