Solved

How to make some of the Windows App.rc file a kind of more persistent? (Version section)

Posted on 2009-04-01
5
756 Views
Last Modified: 2012-05-06
Hi,

I am using Microsoft Visual Studio 2008 and its VC++ 9 to build the application. The App.rc resource file contains the VERSIONINFO section like this

/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
 FILEVERSION 3,5,0,310
 PRODUCTVERSION 3,5,0,310
 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", "The tool..."
            VALUE "CompanyName", "Company, ltd."
            VALUE "FileDescription", "TheApplication"
            VALUE "FileVersion", "3.5.0.310o6-mp1"
            VALUE "InternalName", "App"
            VALUE "LegalCopyright", "Copyright © 1993-2009"
            VALUE "OriginalFilename", "App.exe"
            VALUE "ProductName", "App 3"
            VALUE "ProductVersion", "3.5.0.310o6-mp1"
            VALUE "SpecialBuild", "o6-mp1"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x0, 1200
    END
END

===================================================================================

... The application uses also version.inc file to capture the information about the version separately. The idea was change slightly its content...

#define APP_MAJORNUMBER          3
#define APP_MINORNUMBER          5
#define APP_MODIFICATIONNUMBER   0
#define APP_BUILDNUMBER        310
#define APP_BUILDEXT              "o6-mp1"
#define APP_DATEYEAR          2009
#define APP_DATEMONTH            3
#define APP_DATEDAY             31

... and use it directly for dynamic change of the App.rc file -- see the snippet below.

However, it is replaced again later by the above content when working with the App.rc file via tools in Visual Studio IDE (not touching the Version information in the resource editor). Do you know any way to solve the problem?

Thanks,
    Petr
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
 
#include "version.inc"
 
#define STR(value) #value
#define STRINGIZE(value) STR(value)
#define APP_FULLVERSION_STR \
  STRINGIZE(APP_MAJORNUMBER) "." \
  STRINGIZE(APP_MINORNUMBER) "." \
  STRINGIZE(APP_MODIFICATIONNUMBER) "." \
  STRINGIZE(APP_BUILDNUMBER) \
  APP_BUILDEXT
 
 
VS_VERSION_INFO VERSIONINFO
 FILEVERSION APP_MAJORNUMBER,APP_MINORNUMBER,APP_MODIFICATIONNUMBER,APP_BUILDNUMBER
 PRODUCTVERSION APP_MAJORNUMBER,APP_MINORNUMBER,APP_MODIFICATIONNUMBER,APP_BUILDNUMBER
 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", "The tool..."
            VALUE "CompanyName", "Company, ltd."
            VALUE "FileDescription", "TheApplication"
            VALUE "FileVersion", APP_FULLVERSION_STR
            VALUE "InternalName", "App"
            VALUE "LegalCopyright", "Copyright © 1993-" STRINGIZE(APP_DATEYEAR)
            VALUE "OriginalFilename", "App.exe"
            VALUE "ProductName", "App 3"
            VALUE "ProductVersion", APP_FULLVERSION_STR
            VALUE "SpecialBuild", APP_BUILDEXT
            VALUE "PrivateBuild", ""
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x0, 1200
    END
END

Open in new window

0
Comment
Question by:pepr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 31

Expert Comment

by:Zoppo
ID: 24038339
Hi pepr,

you can try moving this code part from the '.rc' file to the '.rc2' file (if existing - if not you'll have to create and include one).

This '.rc2' file isn't touched by VS resource editors but is included while compiling resources.

Hope that helps,

ZOPPO

0
 
LVL 29

Author Comment

by:pepr
ID: 24038850
Thanks, Zoppo, for your fast reaction. Should I include the App.rc2 file into App.rc? I have added the App.rc2 to the Resource Files section in the project. However, it seems to be ignored.
0
 
LVL 31

Accepted Solution

by:
Zoppo earned 500 total points
ID: 24039008
Hi again,

so there wasn't a '.rc2' file? If so in the '.rc' file a entry needs to be added to TEXTINCLUDE 3 block.

You can do this automatically via the dialog 'Resource Includes' (in VS 2008 you can find it in the context menue of the 'App.rc' in the 'Resource View', in VS 6.0 you can find it in the 'View' menu, for other versions I don't exactly know).

In the dialog just add the include directive in the field 'Compile-time directives', i.e.:

> #include "App.rc2"

Maybe you need to check if you insert it in the correct place, there may exist some #ifdef/#endif pairs - best is to check if there's already included something and add your line directly below these ...

Hope that helps,

ZOPPO
0
 
LVL 29

Author Closing Comment

by:pepr
ID: 31565273
This was simply the excelent answer. Exactly what I hoped for. Thanks a lot. ;)
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 24051616
You're welcome - I'm glad I could help.

Have a nice day,

best regards,

ZOPPO
0

Featured Post

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
print bytes of an integer 6 21
Disable SSL 3 6 27
Hide shared folder for some users 2 26
Windows 10 updates being installed on Windows 7?? 20 40
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
An article on effective troubleshooting
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question