Question
I have a .rc file which is used to include some text data in my executable, like this:
1234 RCDATA myfile.txt
This works fine: the content of the 'myfile.txt' is included in my executable. The problem is that no 0-terminator is added to the string, and I cannot add it to the file. Is there any way of adding a 0-terminator from within the .rc file? Something like this:
1234 RCDATA { myfile.txt, "\0" } // error RC2104
Note that I already found this solution, but I am looking for something more elegant.
1234 RCDATA myfile.txt
1235 RCDATA { "\0" }
Thanks alot, eli
Solution
I don't think so, unless you write your own resource compiler.
I have not meet one which allowed to build one resource from several sources.
You may write a small utility to add a trailing '\0' to a file, say makeZ.exe,
and set an additional build step:
makeZ myfile.txt myfileZ.txt
In you .rc there will be
1234 RCDATA myfileZ.txt
OTHER TIPS
Alternatively, you could look at embedding the data in the RC itself, as per this slice out of the GORC manual:
0x3333 RCDATA
BEGIN
"Hello world"
"Hello world (zero terminated)\0"
L"A Unicode version of the above\0"
0x9999 ;hex number stored as a word
END
MyRes RCDATA
BEGIN
1034 ;decimal number stored as a word
END
MyRes MyResType
BEGIN
10456L ;decimal number stored as a dword
1234L,56666L,99999L ;decimal numbers stored as dwords
END
34h 100h
BEGIN
33hL,34hL,35hL,36hL ;hex numbers stored as dwords
0x37L,0x38L,0x39L,0x40L ;C-style hex numbers stored as dwords
END
You'd better put the trailing character in the file itself. If myfile.txt is stored in ANSI you need one trailing byte, if myfile.txt is stored in Unicode you need two trailing bytes, and your RCDATA statement can't switch on it.