13

What steps are needed to compile Version Information inside a windows DLL from the command line. I have been looking at VersionInfo files, but could not figure out how to link them to the DLL.

Thank you

CharlesB
  • 86,532
  • 28
  • 194
  • 218
adk
  • 4,479
  • 9
  • 36
  • 38

3 Answers3

18

You need to create a version resource and add it to your project. This can be very easily done from within visual studio. in VS 2008, right click a folder of the project, choose add and under "Visual C++" select "Resource File" (not resource template), in the resource file just created you'll be able to add a version resource which looks like this:

VS_VERSION_INFO VERSIONINFO
 FILEVERSION 1,0,0,1
 PRODUCTVERSION 1,0,0,1
 FILEFLAGSMASK 0x17L
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x4L
 FILETYPE 0x1L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904b0"
        BEGIN
            VALUE "FileDescription", "XXX Application"
            VALUE "FileVersion", "1, 0, 0, 1"
            VALUE "InternalName", "XXX"
            VALUE "LegalCopyright", "Copyright (C) 2010"
            VALUE "OriginalFilename", "XXX.exe"
            VALUE "ProductName", "XXX Application"
            VALUE "ProductVersion", "1, 0, 0, 1"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 1200
    END
END

From the command line you'll need to use rc.exe, the resource compiler and then link the result to your dll.

shoosh
  • 76,898
  • 55
  • 205
  • 325
  • 1
    http://stackoverflow.com/questions/852568/version-resource-in-dll-not-visible-with-right-click was also helpful. – E-rich May 09 '14 at 16:35
7

Right-click project name in solution explorer, select Add then Resource. Select Version. In the bottom pane of the newly created VS_VERSION_INFO just modify each value accordingly, re-build and then there will be version info.

Jason Newland
  • 481
  • 5
  • 3
  • The question wasn't especially for Visual Studio but since I'm using it I was helped by this, and voted. Perhaps you should add info that it is for Visual Studio – 244an Mar 23 '17 at 15:58
  • This method is the most straightforward for visual studio ! – Jeff T. Sep 01 '17 at 03:32
2

You normally put a VersionInfo resource into your .rc file and compile it with the resource compiler (rc.exe). Unfortunately, I don't know of any (recent) documentation of the source format. Imitating what VS produces seems to work all right though...

Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111