Hi everyone !

My aim is to train myself with resources (exactly here : icons).
I adapted in HLA one sample program I found in the MSDN library, about changing the icon of an *.exe (calc) by copying it from another one (winmine).

I think my code is rather accurate now, except that I have trouble with the following topics :

the functions FindResource and UpdateResource use MACRO's named :
1' - MAKEINTRESOURCE which returns a lpStr ;
2' - MAKELANGID which returns a word specifying a language ID ;

My questions are :
1 - how is it to use properly the macro-call (MAKEINTRESOURCE or MAKELANGID) inside a HLA function-call (FindResource or UpdateResource) AND how do I know the value to pass to that macro ;
2 - if need, how can I eventually bypass that macro-call, replacing it by the number or the name of the resource I'm trying to locate (that is : how to locate the Icon resource in the *.exe (winmine) ;

Here is my code :

program Icons;


#include( "stdlib.hhf" )
#include( "fileio.hhf" )
#include( "w.hhf" )

static
hFich1: dword;
hRessource1: dword;
hResLoad: dword;
lpResLock: dword;
hUpdateRes: dword;
dwSizeRes: dword;
bE_U_R: dword;
bFreeLib: dword;
bresult: dword;
endstatic;

begin Icons;

// STEP 1 - load *.exe from which find the resource (WINMINE.EXE)

w.LoadLibrary("C:\WINNT\system32\winmine.exe");
mov(eax,hFich1);
stdout.put(nl," hFich1 ",hFich1);


// STEP 2 - find resource into *.exe (ICON)

w.FindResource
(
hFich1,
#1, //MAKEINTRESOURCE(?), [color=red]<-- what is here to pass as a param. value ?[/color] "RT_ICON"
);
mov(eax,hRessource1);
stdout.put(nl," hRessource1 ",hRessource1);


// STEP 3 - load resource from *.exe

w.LoadResource(hFich1,hRessource1);
mov(eax,hResLoad);
stdout.put(nl," hResLoad ",hResLoad);


// STEP 4 - lock resource

w.LockResource(hResLoad);
mov(eax,lpResLock);
stdout.put(nl," lpResLock ",lpResLock);


// STEP 5 - open file to which add the resource (CALC_COPY.EXE)

w.BeginUpdateResource("C:\WINNT\system32\calc_copy.exe",false);
mov(eax,hUpdateRes);
stdout.put(nl," hUpdateRes ",hUpdateRes);

// pre-STEP 6 - size of resource
w.SizeofResource(hFich1,hRessource1);
mov(eax,dwSizeRes);
stdout.put(nl," dwSizeRes ",dwSizeRes);

// STEP 6 - add resource to the updatelist

w.UpdateResource
(
hUpdateRes,
"RT_ICON",
#1,
1, //MAKELANGID [color=red]<-- what is here to pass as a param. value ?[/color] (LANG_NEUTRAL,SUBLANG_NEUTRAL),
lpResLock,
dwSizeRes
);
mov(eax,bresult);
stdout.put(nl," bresult ",bresult);


// STEP 7 - write changes to updated file (CALC.EXE)

w.EndUpdateResource(hUpdateRes, false);
mov(eax,bE_U_R);
stdout.put(nl," bE_U_R ",bE_U_R);


// STEP 8 - clean up

w.FreeLibrary(hFich1);
mov(eax,bFreeLib);
stdout.put(nl," bFreeLib ",bFreeLib);

end Icons;


Who can help me finding what is wrong here ?
(I hope I was clear enough, in other case, I give more explanations :oops: )

Thanks a lot for answering or eventually redirecting me to another more appropriate forum...

Juan,
Belgium.
Posted on 2004-12-08 05:05:49 by Juan