|
|
Home » Developing U++ » External resources » On Windows: Creating VERSIONINFO for your binaries...
On Windows: Creating VERSIONINFO for your binaries... [message #11526] |
Sun, 16 September 2007 17:18  |
 |
tvanriper
Messages: 85 Registered: September 2007 Location: Germantown, MD, USA
|
Member |
|
|
I noticed no topic regarding this subject in the forum, and figured some folks might want some information about it here, rather than having to hunt around for it.
I'll describe a fairly simple way to provide version information for your Windows application, such that one can right-click on the executable in Windows Explorer, and click 'Properties' to see what version of the product they're running. Note that if you intend to use MSI (Microsoft Installer) to install your application, you will need this if you want to properly support patching your product.
The linker links your file version information from resources. This means you need to create a resource file bearing your file version information. Note that you also need to do this to have your application show an icon for itself in Windows Explorer. To include a resource file in your project in TheIDE, just tap Ctrl-I (or right-click in the files area and select 'Insert any file(s)...'), then type in any filename ending with ".rc". TheIDE is smart enough to know that this is a resource file, and will run your resource compiler for this file.
The version information block should look much like this:
#include <windows.h>
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1, 0, 0, 1
PRODUCTVERSION 1, 0, 0, 1
#ifdef DEBUG
FILEFLAGSMASK VS_FF_DEBUG | VS_FF_PRERELEASE
#else
FILEFLAGSMASK 0
#endif
FILEOS VOS__WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", "My Super Amazing Application\0"
VALUE "CompanyName", "Cheese Olfactory Workshop\0"
VALUE "FileDescription", "Provides a /dev/null device for Windows.\0"
VALUE "FileVersion", "1.00.00.01\0"
VALUE "InternalName", "DEVNULL\0"
VALUE "LegalCopyright", "Copyright (C) 1967-2007, Cheese Olfactory Workshop, All rights reserved\0"
VALUE "OriginalFilename", "devnull.exe\0"
VALUE "ProductName", "DevNull\0"
VALUE "ProductVersion", "1.00.00.01\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0409, 0x04B0
END
END
Notice the trailing \0 characters... those are important. Without them, you won't have a proper information block, and while the numeric fields seem to be in place, nobody can see the string information (they'll be dropped, I think).
Also notice that I've included Windows.h. This allows you to use the VS_FF_DEBUG, VS_FF_PRERELEASE, VOS__WINDOWS32, VFT_APP, and VFT2_UNKNOWN 'keywords'. If you do not want to include windows.h, you'll have to figure out these values for yourself.
If you're making a DLL instead of an EXE, you want VFT_APP to be changed to VFT_DLL.
If your application is intended to run on specific OSes (not just any WIN32 machine), you might want to change VOS__WINDOWS32 to something more specific. You can choose from the following:
- VOS_UNKNOWN The operating system for which the file was designed is unknown.
- VOS_DOS File was designed for MS-DOS.
- VOS_NT File was designed for Windows Server 2003 family, Windows XP, Windows 2000, or Windows NT.
- VOS__WINDOWS16 File was designed for 16-bit Windows.
- VOS__WINDOWS32 File was designed for 32-bit Windows.
- VOS_DOS_WINDOWS16 File was designed for 16-bit Windows running with MS-DOS.
- VOS_DOS_WINDOWS32 File was designed for 32-bit Windows running with MS-DOS.
- VOS_NT_WINDOWS32 File was designed for Windows Server 2003 family, Windows XP, Windows 2000, or Windows NT.
You can find more detailed information on this subject at Microsoft's web site. At the moment, this URL seems to present the topic nicely:
http://msdn2.microsoft.com/en-us/library/aa381058.aspx
|
|
|
|
Re: On Windows: Creating VERSIONINFO for your binaries... [message #11635 is a reply to message #11526] |
Wed, 19 September 2007 22:19   |
 |
tvanriper
Messages: 85 Registered: September 2007 Location: Germantown, MD, USA
|
Member |
|
|
If you search on this topic through Google, you'll find that a lot of people would like to auto-increment the file version information (distinct from the product version information) based on something that ensures each updated version of the file is of a 'greater' version than the previous one. Developers often forget to increment the file version information on release, leading to problems when deploying the application (something I've experienced personally).
Microsoft uses the current date/time to help generate that number. I think that's a decent approach. Perhaps a combination of the product version and the date/time, somehow.
I think, if you did this in a somewhat automated fashion, you'd make an awful lot of developers out there happy.
I'd also be concerned about having to remember other twiddly bits... getting the FILEOS or FILETYPE/FILESUBTYPE right, etc.
On the other hand, I can see where some folks might not want to have this automated.
I'm not one of them, though. Heh.
|
|
|
|
Re: On Windows: Creating VERSIONINFO for your binaries... [message #11652 is a reply to message #11526] |
Thu, 20 September 2007 15:51   |
 |
tvanriper
Messages: 85 Registered: September 2007 Location: Germantown, MD, USA
|
Member |
|
|
You may notice that there are two different version numbers.
The product version differentiates between products.
The file version differentiates between files.
When people talk about auto-incrementing a version number, it's the file version they're generally talking about. And it's essential that this version increments (and never decrements), as the Microsoft Installer requires this in order to work properly (if it ever decrements, the decremented file will not install over the previous version).
The product version doesn't matter, with regards to the installer.
So, when you mention how this collaborates with a concurrent versioning system, I'm unsure if you mean product version or file version.
Some folks may not use a concurrent versioning system, so you probably don't want to make that a requirement (but perhaps an option). A handy alternative is the date. Or manual.
I think the most trivial way to implement version number increment (for product and/or file versions) may involve integrating the versioning mechanism with Esc, then exposing certain base choices in Esc. Add a dash of GUI on top of all this, and it might not be so bad for the user.
|
|
|
Re: On Windows: Creating VERSIONINFO for your binaries... [message #14617 is a reply to message #11652] |
Tue, 04 March 2008 17:18   |
nixnixnix
Messages: 415 Registered: February 2007 Location: Kelowna, British Columbia
|
Senior Member |
|
|
An option to have automatic build numbering and to autogenerate the VERSIONINFO (once it has been setup) would be great.
Mirek, I wasn't sure from the above whether you will implement this in the near future. If so, will you post in this thread?
Nick
p.s. I don't see mention on MSDN of how to set the application icon.
[Updated on: Tue, 04 March 2008 17:43] Report message to a moderator
|
|
|
|
Re: On Windows: Creating VERSIONINFO for your binaries... [message #14793 is a reply to message #11526] |
Fri, 14 March 2008 20:43   |
 |
tvanriper
Messages: 85 Registered: September 2007 Location: Germantown, MD, USA
|
Member |
|
|
I've seen it show up on Vista without issue.
Right-click on application in Windows Explorer, select 'Properties', click on 'Details' tab, and I can see the the following:
- File description
- Type
- File version
- Product name
- Product version
- Copyright
- Size
- Date modified
- Language
I develop on a Vista system (despite my dislike for the OS).
[Updated on: Fri, 14 March 2008 20:45] Report message to a moderator
|
|
|
|
|
|
Goto Forum:
Current Time: Sat Apr 26 14:52:18 CEST 2025
Total time taken to generate the page: 0.00763 seconds
|
|
|