I am using Pelles C version 8.00.60 on Windows XP 32-bit.
In short:Macros that are used in the .RC file get expanded when the Resource is edited inside the Pelles C IDE.
More detail:I am programming a dialog-based application and I want to have an About box showing version, build date and copyright. My program already has this information in the Resource and I want to use it.
The crazy way is to retrieve that information when the program runs, by calls to:
- FindResource()
- LoadResource()
- VerQueryValue()
The sane way is to use a header file defining the string literals that are then used in the Resource. That header file can then be reused in the source code, keeping everything straightforward and simple.
This is the way I've chosen but Pelles C keeps expanding the macros in the Resource, forcing me to write-protect the .RC file.
Here is a listing of a sample Resource file, followed by the auto-modified one when I added OriginalFilename in Pelles C:
// RESOURCE SCRIPT generated by "Pelles C for Windows, version 8.00".
#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
#include "Version.h"
LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
FILEFLAGSMASK 0x3F
FILEFLAGS 0x0
FILEOS VOS__WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE VFT2_UNKNOWN
{
BLOCK "StringFileInfo"
{
BLOCK "040904B0"
{
VALUE "Comments", ViComments
VALUE "CompanyName", ViCompanyName
VALUE "FileDescription", ViFileDescription
VALUE "FileVersion", ViFileVersion
VALUE "LegalCopyright", ViLegalCopyright
VALUE "ProductVersion", ViProductVersion
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x409, 0x4B0
}
}
// RESOURCE SCRIPT generated by "Pelles C for Windows, version 8.00".
#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
#include "Version.h"
LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
FILEFLAGSMASK 0x3F
FILEFLAGS 0x0
FILEOS VOS__WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE VFT2_UNKNOWN
{
BLOCK "StringFileInfo"
{
BLOCK "040904B0"
{
VALUE "Comments", "useless program\0"
VALUE "CompanyName", "Frobtech\0"
VALUE "FileDescription", "useless file\0"
VALUE "FileVersion", "0.0.0.0\0"
VALUE "LegalCopyright", "(c) 1990 Marge Simpson\0"
VALUE "OriginalFilename", "ruin_my_res.exe\0"
VALUE "ProductVersion", "1.1.1.1\0"
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x409, 0x4B0
}
}
Suggested fix:Make it so that macros aren't expanded in .RC files.
Attached below is a small project that can be used to check this problem.