?
Solved

Attach a version stamp to a C++ EXE

Posted on 2006-05-05
15
Medium Priority
?
398 Views
Last Modified: 2012-06-27
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.
0
Comment
Question by:plq
  • 8
  • 7
15 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 16615508
>>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
 
LVL 8

Author Comment

by:plq
ID: 16615636
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
 
LVL 86

Expert Comment

by:jkr
ID: 16615668
Is the .rc file being added to your project? If not, you'll need to do that manually.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 8

Author Comment

by:plq
ID: 16615741
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
 
LVL 8

Author Comment

by:plq
ID: 16615756
I tried changing
#include "afxres.h"
to
#include <afxres.h>

same prob
0
 
LVL 86

Expert Comment

by:jkr
ID: 16615776
Is that a MFC project? If not, open the .rc file with an editor and remove

#include "afxres.h"
0
 
LVL 86

Expert Comment

by:jkr
ID: 16615791
Oh, and if it is an MFC project, make sure that the INCLUDE paths for the resource compiler contains the MFC 'include' directory.
0
 
LVL 86

Expert Comment

by:jkr
ID: 16615817
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
 
LVL 8

Author Comment

by:plq
ID: 16615981
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
 
LVL 86

Expert Comment

by:jkr
ID: 16616063
Actually, you should see the .rc file in a folder called 'Resource Files'. BTW, which version of VC++ are you using?
0
 
LVL 8

Author Comment

by:plq
ID: 16618100
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
 
LVL 8

Author Comment

by:plq
ID: 16618118
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
 
LVL 86

Accepted Solution

by:
jkr earned 2000 total points
ID: 16618368
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
 
LVL 8

Author Comment

by:plq
ID: 16618416
Grade A++

Once again, Thank you jkr !
0
 
LVL 86

Expert Comment

by:jkr
ID: 16618425
You're most welcome - I myself started scratching my head ;o)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

850 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