News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Getting my head around resource file compilation

Started by Anaryl, February 25, 2016, 11:53:18 PM

Previous topic - Next topic

Anaryl

Okay, so I got it to work.

It seemed that the trick required was to give rc.exe admin privileges and rename the resource file to rsrc.rc then > assemble asm >compile resource file >link obj > run program.

In regards to the previous post

I took the code from here http://www.programminghorizon.com/win32assembly/tut8.html and whilst it is all well and good to say "This code is bad" may I trouble you to ask why is it bad?

[edit] I somehow broke it again.

Quote** Start A:\masm32\MasmBasic\Res\bldallRM.bat
***** user-defined OPT_xx variables: ***

*** anawin3.rc not found, will try rsrc.rc ***
OPT_Arg1:
OPT_Arg2:
OPT_Out:  "anawin3.exe"
OPT_Res:  rsrc


*** Assemble, link and run anawin3 ***

*** Resource "rsrc.rc" could not be created ***

So I decided I would just start modifying the files and poking around. But for some reason it broke it again. Going to keep messing with it.

Aha so it just wont compile at all in event of syntax errors. Well still I have learned something now.

So my next question is do I always have to call .rc files rsrc?

jj2007

Quote from: Anaryl on March 08, 2016, 11:39:04 PMAha so it just wont compile at all in event of syntax errors.

Yes, that is normal behaviour.

QuoteSo my next question is do I always have to call .rc files rsrc?

Depends on the editor/IDE. RichMasm, for example,

- checks if anawin3.rc exists; if no, if rsrc.rc exists; if one of them is present, rc.exe will be called before linking;

- examines the code for "Windows" keywords such as Load, WM_CREATE etc, then for "console" keywords such as print, inkey, StdOut, and instructs the linker to use the appropriate subsystem.
etc...

I don't think you need admin rights for rc.exe (I never needed them). Your problem seems to be that no window is created, due to the missing RegisterClassEx. In RichMasm, click on File/New Masm source, then pick Simple window (Masm32) from the templates. It has all you need for creating a simple window. Besides, at the end of the file you can edit the resources, too - the rc file gets created when you hit F6 to build the project.

Note: If after a successful build (no assembly, linker or rc errors) you get "access denied", the reason may be that a windows application hangs in an endless loop somewhere (missing RegisterClassEx...). In RichMasm, one way to test this is to put, at the end of the code, OPT_Susy Console to force subsystem console. Then, you can insert print "creating main window" or whatever debugging message you need to find out where exactly it hangs.

TouEnMasm

************So my next question is do I always have to call .rc files rsrc?****************

You choose the name you want for the rc file,.txt if you want,this work.
The only rule is that the linker must find it when he assemble the module .
link ........ asm.obj  Myresource.bin                ;for example.

To compile a rc file you need those two progs:
   Rc.exe /v %FILE%.rc
   Cvtres.exe /machine:ix86 /out:%FILE%.bin %FILE%.res
the /out: of cvtres allow you to name it as you want.

Here is a batch file for training,the anawin1 play with names




Fa is a musical note to play with CL

Anaryl

Thanks for that Tout, I will start playing around with them now. I'm starting to get my head around the res compilation. Still seems a bit fiddly at times where I am like reloading the file or editor to get it to work but I think I am getting the hang of it.

I will have a play around with these now so I can get a better handle (ahem) on the language and concepts therein. Thanks heaps for the help you guys.