PDA

View Full Version : Version Info in EXE, Access project file from resource.rc file?



HappyCoder
15th March 2016, 16:34
Hello,

i'm using this to include version information to my compiled EXE file:
http://stackoverflow.com/questions/2784697/setting-application-info-in-a-qt-executable-file-on-windows

resources.rc


#include <windows.h>

#define VER_FILEVERSION 2,1,3,924
#define VER_FILEVERSION_STR "2.1.3.924"
#define VER_PRODUCTVERSION 2,1,3,924
#define VER_PRODUCTVERSION_STR "2.1.3"

#define VER_COMPANYNAME_STR "Cool Company Pty Ltd"
#define VER_FILEDESCRIPTION_STR "Cool Program"
#define VER_INTERNALNAME_STR "Cool Program"
#define VER_LEGALCOPYRIGHT_STR "Copyright 2012 Cool Company Pty Ltd"
#define VER_LEGALTRADEMARKS1_STR ""
#define VER_LEGALTRADEMARKS2_STR ""
#define VER_ORIGINALFILENAME_STR "application.exe"
#define VER_PRODUCTNAME_STR "Cool Program"

#ifndef DEBUG
#define VER_DEBUG 0
#else
#define VER_DEBUG VS_FF_PRIVATEBUILD|VS_FF_PRERELEASE|VS_FF_DEBUG
#endif


IDI_ICON1 ICON DISCARDABLE "ICON.ico"

VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILEVERSION
PRODUCTVERSION VER_PRODUCTVERSION
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK

FILEFLAGS ( VER_DEBUG )
FILEOS VOS__WINDOWS32
FILETYPE VFT_APP
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", VER_COMPANYNAME_STR
VALUE "FileDescription", VER_FILEDESCRIPTION_STR
VALUE "FileVersion", VER_FILEVERSION_STR
VALUE "InternalName", VER_INTERNALNAME_STR
VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR
VALUE "LegalTrademarks1", VER_LEGALTRADEMARKS1_STR
VALUE "LegalTrademarks2", VER_LEGALTRADEMARKS2_STR
VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR
VALUE "ProductName", VER_PRODUCTNAME_STR
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
END
END

BLOCK "VarFileInfo"
BEGIN
/* The following line should only be modified for localized versions. */
/* It consists of any number of WORD,WORD pairs, with each pair */
/* describing a language,codepage combination supported by the file. */
/* */
/* For example, a file might have values "0x409,1252" indicating that it */
/* supports English language (0x409) in the Windows ANSI codepage (1252). */

VALUE "Translation", 0x409, 1252

END
END


Questions:

I have also some parameters in my Qt project file, like this:

project.pro


VERSION = 11.0.5
DEFINES += APP_VERSION=\\\"$$VERSION\\\"


How can i access e.g. VERSION (located in my project.pro) from resources.rc?

Thx

anda_skoa
15th March 2016, 17:55
Hmm, what if you do it the other way around.

The rc file can obviously include headers, so you could have a simple header that just contains


#define VERSION 11.0.5

And then use cat() and section() in the .pro to extract the version string into a qmake variable.

Cheers,
_

HappyCoder
18th March 2016, 11:51
And then use cat() and section() in the .pro to extract the version string into a qmake variable.


Thx, works great!