views:

957

answers:

3

I have a number of VC 6.0 projects (dsps) which build into dlls which don't have resource files. Any idea how to add resources into an existing project?

The project is due for a major release shortly and I want to add a fileversion to those dlls currently lacking one. The dlls will be recompilied before release so I'm just trying to make these dsps like all the others I've inherited with this project (that do have a file and product version etc so that we can easily tell exactly what is running on a customer's machine.

One answer : Create an *.rc and resource.h file (copy from another project?) and add it to the source folder of ypur project in VC6 file view. The resource view is automatically created. Thanks for your help guys, gave me the pointers I needed.

A: 

You can always try use editbin /VERSION:#[.#] to change the version within the dll itself. Otherwise, it should be an entry in the resource file of the project.

xtofl
Thanks, you've helped clarify what I should be asking :)
Patrick
+6  A: 

Just add a VERSIONINFO block to the resource file for the DLL.

Open the .rc file, and use "Insert/Resource.../Version" and you'll get a new VERSIONINFO resource with a bunch of defaults. If the project does not already have a resource file, you can add one using "File/New.../Resource Script".

If you want to roll your own, an example VERSIONINFO block is given on the MSDN page for VERSIONINFO:

#define VER_FILEVERSION             3,10,349,0
#define VER_FILEVERSION_STR         "3.10.349.0\0"

#define VER_PRODUCTVERSION          3,10,0,0
#define VER_PRODUCTVERSION_STR      "3.10\0"

#ifndef DEBUG
#define VER_DEBUG                   0
#else
#define VER_DEBUG                   VS_FF_DEBUG
#endif

VS_VERSION_INFO VERSIONINFO
FILEVERSION     VER_FILEVERSION
PRODUCTVERSION  VER_PRODUCTVERSION
FILEFLAGSMASK   VS_FFI_FILEFLAGSMASK
FILEFLAGS       (VER_PRIVATEBUILD|VER_PRERELEASE|VER_DEBUG)
FILEOS          VOS__WINDOWS32
FILETYPE        VFT_DLL
FILESUBTYPE     VFT2_UNKNOWN
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
Michael Burr
The dlls don't have resource files! When you open up the project there is the class and file view but no resource view nor any *.rc in the project directory... Can I just create an rc file and add it like I would a cpp?
Patrick
Yup - when you've opened the new .rc file, you can just right click on the root node of the resources and select 'Insert...' to add a new Version resource with many of the fields defaulted for you.
Michael Burr
A: 

Patrick,did adding the versioninfo block actually add the versioning to your DLL? And by actual I mean when you hover the mouse over the binary does the versioning popup... or right-click>Properties>Details shows no versioning either...

This works for exe(s), but whenever I add versioninfo blocks to a library nothing shows up.

EB

Okay, thought I would share my ignorance today... apparently this versioning only really works for exe(s) and dll(s) so ends my hope to use it on static libraries for a quick view of the versioning

echobravo
Yes, I get the version in the properties pop up
Patrick