views:

397

answers:

2

I don't know RC scripts.

I want to include Product version, File version, etc. metadata into a DLL I'm building. I'm using an .rc file to do that. The build is makefile driven. I'm following along with an example .rc scrpit I found.

The template .rc file includes afxres.h , but I don't think I need that. But if I just remove it I get a bunch of compile errors.

What does a basic, non-MFC RC script look like? Can I remove all the stuff like this:

/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32

....
+1  A: 

My answer:
NO, I don't need all that crap. Here's an RC script that works for VERSIONINFO.

#define VER_FILEVERSION          1,2,3,4
#define VER_FILEVERSION_STR      "1.2.3.4"
#define VER_PRODUCTVERSION       1,2,0,0
#define VER_PRODUCTVERSION_STR   "1.2.0.0"

// -------------------------------------------------------

VS_VERSION_INFO VERSIONINFO
 FILEVERSION            VER_FILEVERSION
 PRODUCTVERSION         VER_PRODUCTVERSION
 FILEFLAGSMASK 0x17L
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x4L
 FILETYPE 0x2L
 FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
    BLOCK "040904b0"
    BEGIN
 VALUE "CompanyName",      "Company X"
 VALUE "FileDescription",  "Description Goes Here"
 VALUE "InternalName",     "NotSure"
 VALUE "LegalCopyright",   "Copyright (C) 2009 Your Name Here"
 VALUE "OriginalFilename", "DllName.dll"
 VALUE "ProductName",      "Product Title"
 VALUE "FileVersion",      VER_FILEVERSION_STR
 VALUE "ProductVersion",   VER_PRODUCTVERSION_STR
    END
END
BLOCK "VarFileInfo"
BEGIN
    VALUE "Translation", 0x409, 1200
END
END

Conmpile it with:

$(WindowsSDK)\bin\RC.exe /FoProjectName.res ProjectName.rc
Cheeso
A: 

I had a similar problem when trying to compile without MFC. The solution of Cheeso would not work adequately for me.

Everything compiled okay, and I saw no errors/warnings during building. The Icon which was defined in my resource file was shown correctly in 'windows explorer'. However, the version data was not available. (Which can be seen when right-clicking on the executable and selection properties. In this case there was no 'version' tab present.)

To get it working I had to add the following include at the top of the .rc file:

#include <windows.h>

With this change, the version tab would show up in the properties of the executable. Also, the .NET System.Diagnostics.FileVersionInfo class is now able to get the version information, while this would not work before.

Defaultly "stdafx.h" would include "windows.h". I'm not sure why windows.h is required, but it seems to make the difference in my case.

Edit: Added some more specific information, in response to Cheeso.

Johan
Are you saying the rc.exe failed to compile the rc script, without that included file? What symbol was not defined? How did it fail?
Cheeso