[madRes] SaveIconGroupResourceW

delphi package - madRes, madTools, madStrings, ...

[madRes] SaveIconGroupResourceW

Postby MarcT » Sat Dec 29, 2007 8:28 am

Hi,

I want to be able to save the MainIcon group of a file to a .ico, so to start, I'm assuming the name of the main icon group is MAINICON, but I'm having a problem, it seems I need to know the resource language, for example, this doesn't work:

Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
var
  resUpdateHandle : dword;
begin

  resUpdateHandle := BeginUpdateResourceW(PWideChar(wideString('calc.exe')), false);
  if resUpdateHandle <> 0 then
  begin

    SaveIconGroupResourceW(resUpdateHandle, 'SC', 0, 'test.ico');
    EndUpdateResourceW(resUpdateHandle, true);
  end;

end;


but this works:


Code: Select all
function MAKELANGID(sPrimaryLanguage : Word;
                    sSubLanguage : Word) : Word;
begin
  result := (sSubLanguage shl 10) or
             sPrimaryLanguage;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  resUpdateHandle : dword;
begin

  resUpdateHandle := BeginUpdateResourceW(PWideChar(wideString('calc.exe')), false);
  if resUpdateHandle <> 0 then
  begin

    SaveIconGroupResourceW(resUpdateHandle, 'SC', makelangid(LANG_FRENCH,SUBLANG_DEFAULT), 'test.ico');
    EndUpdateResourceW(resUpdateHandle, true);
  end;

end;



lol it works because I know my calc.exe is in french but I wouldn't normally know this for a file,

so how can I fix this?:/

thx
MarcT
 
Posts: 4
Joined: Sat Dec 29, 2007 8:15 am

Postby ciuly » Sat Dec 29, 2007 8:53 am

I suppose you are marc582 from EE :P

you need to enumerate the icons and store their info before making generic changes. see this thread: http://forum.madshi.net/viewtopic.php?t=273
ciuly
 
Posts: 62
Joined: Mon Apr 30, 2007 1:16 pm
Location: Romania

Postby MarcT » Sat Dec 29, 2007 8:58 am

lol yes, I am,

ok so, from what I've seen, the guy on the thread seems to ignore the language:

I can save the main icon like this:
result := SaveIconGroupResourceW(resUpdateHandle, 'MAINICON', 0, 'c:\test.ico');

But how do I save an icon called "74" from RT_ICONS?
result := SaveIconGroupResourceW(resUpdateHandle, 'RT_ICON_74', 0, 'c:\test2.ico'); // does not work


he use 0,

why?

I thought the enumerating thing was just to know the icon group, we also use this to know the language of icon?

damn I'm becoming bored, I'm trying to do this since so many days... :S


Marc and thx.
MarcT
 
Posts: 4
Joined: Sat Dec 29, 2007 8:15 am

Postby ciuly » Sat Dec 29, 2007 9:09 am

well he only needed names :)
you will have to call EnumResourceLanguages instead of EnumResourceNames to save the languages as well ;) (EnumResourceLanguages also passes you the names so no problem there)
ciuly
 
Posts: 62
Joined: Mon Apr 30, 2007 1:16 pm
Location: Romania

Postby MarcT » Sat Dec 29, 2007 9:35 am

mmm ok thx but mmm

give me more hint plz, i hate those fucking api, i never know what to fill as parameter, msdn is never clear :@
MarcT
 
Posts: 4
Joined: Sat Dec 29, 2007 8:15 am

Postby ciuly » Sat Dec 29, 2007 10:32 am

for future reference, discussion will be continued here: http://www.experts-exchange.com/Program ... 46543.html
ciuly
 
Posts: 62
Joined: Mon Apr 30, 2007 1:16 pm
Location: Romania


Return to madBasic

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

cron