Attach a version stamp to a C++ EXE

I've found this and followed the instructions

       http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_20841269.html

When I do it the MSVC++ way, I get errors in the IDE saying that one of the include files cant be found

When I paste jkr's first comment it compiles ok but the version information still doesn't appear on the EXE properties

I've tried also dragging the version file into the ide and adding it to file view, but nothing seems to get the version info appearing.

The application is a simple EXE with no windows interface.
LVL 8
plqAsked:
Who is Participating?
 
jkrCommented:
Argh, it seems the LANGUAGE attribute is mandantory. OK, here's what I did to test that:

rctest.rc
------------------------>8--------------------------
#include <winres.h>

LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT

///////////////////////////////////////////////////////////////////////
//
// 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 0x4L
 FILETYPE 0x1L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904b0"
        BEGIN
            VALUE "Comments", "Sample Application\0"
            VALUE "CompanyName", "Microsoft Corp.\0"
            VALUE "FileDescription", "MyProject MFC Application\0"
            VALUE "FileVersion", "1, 0, 0, 1\0"
            VALUE "InternalName", "MyProject\0"
            VALUE "LegalCopyright", "Copyright (C) 1999\0"
            VALUE "OriginalFilename", "MyProject.EXE\0"
            VALUE "ProductName", "MyProject Application\0"
            VALUE "ProductVersion", "1, 0, 0, 1\0"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 1200
    END
END
------------------------>8--------------------------

rctest.cpp:
------------------------>8--------------------------
void main () {

}
------------------------>8--------------------------

On the command line:

rc.exe rctest.rc
cl.exe rctest.cpp /link rctest.res

and you have the version info in rctest.exe

Just add

#include <winres.h>

LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT

to the .rc file (at the top) and you're done.
0
 
jkrCommented:
>>When I do it the MSVC++ way, I get errors in the IDE saying that one of the include files cant be found

Which file is reported as 'missing'?

>>When I paste jkr's first comment it compiles ok but the version information still doesn't appear on the EXE
>>properties

Where are you pasting it?
0
 
plqAuthor Commented:
Hi jkr

OK I've moved on slightly from there, in the sense that doing it the MSVC++ way, the entries now appear under "Resource Files" in file view. However if I close those files in the IDE, close the project and reopen it, the "Resource Files" entry is empty again.

How can I "make it stick"

So far...

1. Open the dsw into the msvc6 ide
2. Insert - Resource - Version - New
3. Save All and save it as an RC in the main source folder
4. Drag and drop the file from windows explorer into the msvc file view
5. Compile the project using buildall-clean and then buildall
6. No version stamp on debug or release exe




0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
jkrCommented:
Is the .rc file being added to your project? If not, you'll need to do that manually.
0
 
plqAuthor Commented:
OK, when I add it manually, I get Fatal Error RC1015 - cannot open include file 'afxres.h'

which was the error I got on my original question
0
 
plqAuthor Commented:
I tried changing
#include "afxres.h"
to
#include <afxres.h>

same prob
0
 
jkrCommented:
Is that a MFC project? If not, open the .rc file with an editor and remove

#include "afxres.h"
0
 
jkrCommented:
Oh, and if it is an MFC project, make sure that the INCLUDE paths for the resource compiler contains the MFC 'include' directory.
0
 
jkrCommented:
BTW, *I* would still go the way and create the .rc file manually (as in the Q you linked) and also add that to your project manually.
0
 
plqAuthor Commented:
OK I had to take out several other bits including the language piece.

I now have script1.rc showing alongside the .cpp files under source files in file view

Now its compiling - but still no version tab in the exes. So I pasted the example off that other EE thread above over script1.rc - and still no version tab

Is there something in project settings ?

thanks
<uppedpoints/>
0
 
jkrCommented:
Actually, you should see the .rc file in a folder called 'Resource Files'. BTW, which version of VC++ are you using?
0
 
plqAuthor Commented:
Sorry - ee not emailing me today

MSVC 6 is the version

"Resource files" seems to refuse to accept files. When I drag and drop the script1.rc file onto "Resource Files" it opens in the main IDE window but does not add itself to the "Resource Files" folder. However I right clicked "Resource Files" and chose "Add Files to Folder", and Script1.rc did finally get added into resource files.

Then I did a clean and compile - and still no version info




0
 
plqAuthor Commented:
Here's the text in script1.rc exactly what you pasted in that old thread


///////////////////////////////////////////////////////////////////////
//
// 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 0x4L
 FILETYPE 0x1L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904b0"
        BEGIN
            VALUE "Comments", "Sample Application\0"
            VALUE "CompanyName", "Microsoft Corp.\0"
            VALUE "FileDescription", "MyProject MFC Application\0"
            VALUE "FileVersion", "1, 0, 0, 1\0"
            VALUE "InternalName", "MyProject\0"
            VALUE "LegalCopyright", "Copyright (C) 1999\0"
            VALUE "OriginalFilename", "MyProject.EXE\0"
            VALUE "ProductName", "MyProject Application\0"
            VALUE "ProductVersion", "1, 0, 0, 1\0"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 1200
    END
END

thanks
0
 
plqAuthor Commented:
Grade A++

Once again, Thank you jkr !
0
 
jkrCommented:
You're most welcome - I myself started scratching my head ;o)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.