Following up on my earlier blog entries about writing a Lotus Notes C-API program in Visual Studio Express (Part 1 and Part 2), here's another thing you might want to do that isn't really obvious.
You know how when you view the properties of most commercial EXE and DLL files, and you see properties like the program description and the version number and so on? For example:
In the full versions of Visual Studio, there is something called the Resource Editor that makes it very easy to create all those properties for your EXE or DLL. However, in the free Visual Studio Express offering that's one of the components they took out.
Luckily, you can still create a resource file and include it with your project, you just have to do it manually. Here's how:
- Open up your favorite text editor and create a resource file (see example below), and save it with an .RC file extension -- you'll probably want to save it in the same directory as the other files in your project
- In your VS-Express project, select the menu option Project - Add Existing Item...
- Change the file type to "Resource Files" and choose the resource file you created
Badda bing, badda boom, you've got yourself a resource file. The next time you compile up your project, it'll have some of those fancy-schmancy properties lists that everyone wants these days.
The exact format and information that you put into a resource file is a little cryptic (which is why there is such thing as a Resource File editor in the first place), but you can usually start with an example and modify it to work for you. Here's the resource file I used for my SoapLog DLL:
//////////////////////////////////////////////////////////
// resource file for soaplog.dll
//////////////////////////////////////////////////////////
#include "soaplog.h"
/*
soaplog.h contains definitions like:
#define RC_FILEVERSION 1,0,3,0
#define RC_FILEVERSION_STRING "1, 0, 3, 0 "
*/
1 VERSIONINFO
FILEVERSION RC_FILEVERSION
PRODUCTVERSION RC_FILEVERSION
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L // 0x1L = EXE, 0x2L = DLL
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
//////////////////////////////////////////////////////////
// The BLOCK number here consists of a 4-digit language
// value (0409 = US English) and a 4-digit codepage
// number, in hex (04e4 = 1252).
//////////////////////////////////////////////////////////
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "http://www.nsftools.com"
VALUE "LegalCopyright", "(c) 2006 Julian Robichaux. All rights reserved."
VALUE "FileDescription", "Domino DSAPI SOAP logging filter"
VALUE "FileVersion", RC_FILEVERSION_STRING
VALUE "InternalName", "soaplog"
VALUE "OriginalFilename", "soaplog.dll"
VALUE "ProductName", "soaplog"
VALUE "ProductVersion", RC_FILEVERSION_STRING
END
END
//////////////////////////////////////////////////////////
// for valid language and charset values below, see:
// http://msdn.microsoft.com/library/en-us/tools/tools/versioninfo_resource.asp
// NOTE that the language value below (409, US English)
// MUST match the StringFileInfo BLOCK number above, and
// the 04e4 suffix on the BLOCK number is a hex version of
// the 1252 codepage that is also defined below.
//////////////////////////////////////////////////////////
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
One thing that is useful to do is to maintain the file version and product version information in a header file (as I did above with RC_FILEVERSION and RC_FILEVERSIONSTRING), because that's something that may change often. Since you can't edit a resource file in VS-Express but you can edit all the header files you want, keeping this information in a header file is a lot easier than having to remember to open the resource file in a separate text editor every time you update the version of your file.
I suppose you could go whole hog and maintain all the String values in a header file, if you really felt like it.
[
permalink ] [
e-mail me ] [
read/add comments ]