摘要:通过预处理器宏在单独维护中定义了版本详细信息version.inc
......如何将宏值包含到资源版本定义块中?
我的version.inc
文件存储在 UTF-8 中(即纯 ASCII 在这种情况下)。其完整内容如下(APS_
这里的前缀与应用的真实名称有关,.aps
与资源编译器生成的文件无关):
#define APS_MAJORNUMBER 4
#define APS_MINORNUMBER 5
#define APS_BUILDNUMBER 0
#define APS_MODIFICATIONNUMBER 0
#define APS_BUILDEXT "wx"
#define APS_DATEYEAR 2012
#define APS_DATEMONTH 10
#define APS_DATEDAY 4
Visual Studio 2012 C++ 似乎对资源脚本文件 ( app.rc
) 比 Visual Studio 2010 更挑剔。我注意到的第一件事是,在手动编辑时,我必须保留 UTF-16 编码。你能证实吗?有这方面的文件吗?
app.rc
说看起来像这样的版本块:
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040504b0"
BEGIN
VALUE "CompanyName", "TODO: <Company name>"
VALUE "FileDescription", "TODO: <File description>"
VALUE "FileVersion", "1.0.0.1"
VALUE "InternalName", "app.exe"
VALUE "LegalCopyright", "Copyright (C) 2012"
VALUE "OriginalFilename", "app.exe"
VALUE "ProductName", "TODO: <Product name>"
VALUE "ProductVersion", "1.0.0.1"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x405, 1200
END
END
在 Visual Studio 的早期版本(2005 和 2010)中,我能够拥有这样的相关信息version.rc2
:
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
#include "version.inc"
#define STR(value) #value
#define STRINGIZE(value) STR(value)
#define APS_FULLVERSION_STR \
STRINGIZE(APS_MAJORNUMBER) "." \
STRINGIZE(APS_MINORNUMBER) "." \
STRINGIZE(APS_BUILDNUMBER) "." \
STRINGIZE(APS_MODIFICATIONNUMBER)
VS_VERSION_INFO VERSIONINFO
FILEVERSION APS_MAJORNUMBER,APS_MINORNUMBER,APS_BUILDNUMBER,APS_MODIFICATIONNUMBER
PRODUCTVERSION APS_MAJORNUMBER,APS_MINORNUMBER,APS_BUILDNUMBER,APS_MODIFICATIONNUMBER
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x29L
#else
FILEFLAGS 0x28L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000004b0"
BEGIN
VALUE "Comments", "A fairly useful tool named APS"
VALUE "CompanyName", "The company name"
VALUE "FileDescription", "app"
VALUE "FileVersion", APS_FULLVERSION_STR
VALUE "InternalName", "aps"
VALUE "LegalCopyright", "Copyright © 1993-" STRINGIZE(APS_DATEYEAR)
VALUE "OriginalFilename", "app.exe"
VALUE "PrivateBuild", ""
VALUE "ProductName", "APS of the version 4"
VALUE "ProductVersion", APS_FULLVERSION_STR
VALUE "SpecialBuild", APS_BUILDEXT
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0, 1200
END
END
然后通过手动编辑将version.rc2
其包含在其中。但是,我无法使用 Visual Studio 2012 项目和资源文件重复该过程。我可能犯了一些我看不见的错误。这种方法是否也适用于 Visual Studio 2012?app.rc
app.rc
感谢您的时间和经验,
彼得