![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|
Q: Add version info to a BCB projectAnswerC++Builder 3.0 and above provide built in support for adding version information for your BCB program. This support can be found on the Version tab of the Project-Options dialog box. In C++Builder 1.0, you must add an RC resource file to your project if you want to include version information. This FAQ applies to BCB 1.0 users, and to users of BCB3, BCB4, and BCB5 who want more flexibility than what is provided by theversion settings in the project options. Most programmers can just use the settings in the project options. Select File | New... from the BCB menu and select the Text object in the object repository. If you don't have an object repository (Standard edition of BCB), create the file using Notepad or some other editor. Save the file as VERSION.RC. Insert the following text into the file, and add the file to your project by selecting the Project | Add To Project menu option. #include <winver.h> 1 VERSIONINFO FILEVERSION 1,0,0,201 PRODUCTVERSION 1,0,0,0 FILEFLAGSMASK 0x3fL FILEFLAGS 0x0L FILEOS VOS_WINDOWS32 FILETYPE VFT_APP FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904B0" BEGIN VALUE "CompanyName", "Bob's Software Inc\0" VALUE "FileDescription", "Bob's Database Program\0" VALUE "FileVersion", "1.001\0" VALUE "InternalName", "buffy\0" VALUE "LegalCopyright", "Copyright \xA9 1998\0" VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "bobdb.EXE\0" VALUE "ProductName", "BobDB\0" VALUE "ProductVersion", "1.0\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1200 END END Note 1: You can use the resource editor from Borland C++ 5, MSVC++ 4.X or 5, or any other Windows compiler to create the version resource for you instead of creating the RC file manually with a text editor. Create the resource, save it to an RC file, and then add it to your BCB project. Note 2: The number 1 before the VERSIONINFO keyword is the resource ID of of the version resource. Sometimes you might see a resource identifier, such as VS_VERSION_INFO, in place of the number 1. In this case, VS_VERSION_INFO would be defined in a header or make file. However, Windows requires that this ID be set to 1. To save time and trouble, I prefer to literally place the value 1 right in the resource. You can use whichever strategy you prefer. Note 3: The lines that follow the VERSIONINFO keyword are called the fixed-info block of the version resource. The fixed-info block ends with the first BEGIN statement. The fixed-info block is important, but it will not normally be seen by users. The table below explains each statement in the fixed-info block: Item Description Examples ------------------------------------------------------------------------- FILEVERSION The version number of the file. 1,0,0,200 PRODUCTVERSION The version number of the product. 1,0,0,0 FILEFLAGSMASK Always set to 0x3fL 0x3fL FILEFLAGS Allows you to mark the app as debug, 0 or pre-release software. Some valid VS_FF_DEBUG values (see winver.h for more choices): 0x0L :normal flag VS_FF_DEBUG :contains debug info VS_FF_PATCHED :has been patched VS_FF_PRERELEASE :still in beta FILEOS Describes the target OS for the app. VOS_WINDOWS32 Some values (see winver.h): VOS_DOS VOS_NT VOS_WINDOWS16 VOS_WINDOWS32 FILETYPE Identifies the file as an app, dll, VFT_APP or driver VFT_APP :application. VFT_DLL :dynamic link library VFT_DRV :device driver VFT_VXD :virtal device driver FILESUBTYPE Subtype is only used when FILETYPE is 0x0L a font or a driver. Set to 0 normally Note 4: So what's the difference between the FILEVERSION and the PRODUCTVERSION? I'll use BCB to explain. C++Builder shipped with version 2.05 of WinSight. If you were designing a version resource for WinSight, you might set the FILEVERSION to 2,0,5,0 because WinSight's version is 2.05, but PRODUCTVERSION would be 1,0,0,0 because WinSight is part of the C++Builder package, and BCB is version 1.00 (if you have BCB3, then adjust the numbers accordingly). The meaning of the FILEVERSION and PRODUCTVERSION is up to you. In general, let's say that your program is on version 2.1.10. You might set the FILEVERSION to 2,1,10,0. Some companies keep track of build numbers (Microsoft does this a lot). You could stick this in the last item. Imagine your program is on build number 738. You could use 2,1,10,738 as your FILEVERSION. The choice is up to you. Here are what some of the programs on my PC use in their version resources. Product FILEVERSIONINFO Help About -------------------------------------------------------- Internet Explorer 4 4, 71, 1712, 0 4.71.1712.6 MS Dev Studio 5, 0, 0, 7022 MS Spy program 4, 0, 0, 0 5.00.7022 MS rc.exe 5, 0, 1472, 1 MS word 8, 0, 0, 3514 MS outlook 8, 2, 1, 4106 8.02.4212 Notice that Microsoft gets a little careless. It looks like somebody forget to alter the version resource for the Spy program. Outlook's version resource contains a 1 that never appears in the help about screen. Plus, look at how those big numbers move around. I assume these big numbers are the build numbers, but Microsoft puts them in different locations for different products. Note 5: The version resource contains two blocks of data between the first BEGIN and the very last END. One block is called the Variable Information Block, and the other is called the String Information Block. The var info block is marked by the line BLOCK "VarFileInfo". The var info block contains a value that is labelled "Translation". The translation value contains two numbers that dennote which languages and character sets your product supports. The first number (0x409 in the example) determines which language the program supports. 0x409 is the code for US English. The second value (1200 in the example) describes the character set. 1200 is the value for the UNICODE set. Other common values are 1252 for Windows Multilingual (word uses this setting), and 0 for 7 bit ascii. For a complete list of language and character set values, look under Language Identifiers and Code Page Identifiers in the Win32 help file. Your version resource can contain multiple values in its var info block. Each value in the var info block will contain a corresponding string info block. The collection of string info blocks begin with the line BLOCK "StringFileInfo" Each string info block contains a BLOCK value that links it to a var info block value. In this example, the BLOCK value is "040904B0". Observe that 0x0409 matches the language setting, and 0x04B0 is 1200 in Hex, which matches the character set. The string info block contains a number of string settings. Some of these settings are required: CompanyName, FileDescription, FileVersion, InternalName, OriginalName, and ProductName. The others are optional. You can even add new strings. For example, Microsoft Word adds two strings called LegalTrademarks1 and LegalTrademarks2. These extra strings will appear when a user views the version info of your program. Note 6: When user views the version info from your program, the dialog box will display the version number from the FileVersion section of the String Info Block. The data from the fixed info block is not displayed. Note: 7 The \xA9 inserts a copyright character into the version resource string. See the example of the LegalCopyright above. Note:8 The sample below shows how to structure a version resource if it needs to contain several values in the Variable Information Block. #include <winver.h> 1 VERSIONINFO FILEVERSION 1,0,0,201 PRODUCTVERSION 1,0,0,0 FILEFLAGSMASK 0x3fL FILEFLAGS 0x0L FILEOS VOS_WINDOWS32 FILETYPE VFT_APP FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904B0" BEGIN VALUE "CompanyName", "Bob's Software Inc\0" VALUE "FileDescription", "Bob's Database Program\0" VALUE "FileVersion", "1.001\0" VALUE "InternalName", "buffy\0" VALUE "LegalCopyright", "Copyright \xA9 1998\0" VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "bobdb.EXE\0" VALUE "ProductName", "BobDB\0" VALUE "ProductVersion", "1.0\0" END BLOCK "041f04e6" BEGIN VALUE "CompanyName", "Bob's Software Inc\0" VALUE "FileDescription", "Bob's DB program ported to Greece\0" VALUE "FileVersion", "1.001\0" VALUE "InternalName", "buffy\0" VALUE "LegalCopyright", "Copyright \xA9 1998\0" VALUE "OriginalFilename", "bobdb.EXE\0" VALUE "ProductName", "Version Application\0" VALUE "ProductVersion", "1.0\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1200, 0x41f, 1254 END END | ||||||
All rights reserved. |