Click here to Skip to main content
15,894,630 members
Articles / Desktop Programming / ATL

Increment File and Product Version Number - Multiple IDE

Rate me:
Please Sign up or sign in to vote.
4.58/5 (32 votes)
21 Oct 2008CPOL12 min read 293.6K   1.2K   134  
An add-in to automatically increment the FileVersion and ProductVersion fields in your application's resource file. Works in VC6 and VS2005, and probably all versions in between.
#ifndef STDAFX_H_10C3F2AB_C971_462D_AE43_8D659E613A34
#define STDAFX_H_10C3F2AB_C971_462D_AE43_8D659E613A34
/**
 * \file stdafx.h
 *
 * \brief Pre-compiled header for the IncVersion project
 *
 * $Id: stdafx.h, v1.1.1.1 2006/09/24 23:13:02 mgh Exp $
 *
 *
 * Copyright (C) 2006 Michael G. Herstine <sp1ff@pobox.com>
 *
 * Permission to use, copy, or modify this source code is hereby granted
 * free of charge, provided that this copyright notice appear on all
 * copies and on all source code derived from this code.  No
 * representation is made regarding the suitability of this software for
 * any purpose.  It is provided "as is" without express or implied
 * warranty.
 *
 *
 * This include file is for standard system include files, or project-
 * specific include files that are used frequently, but are changed
 * infrequently.
 *
 *
 */

////////////////////////////////////////////////////////////////////////////
// Modified by Jordan Walters, 01.03.2008 for multi-IDE version increment //
////////////////////////////////////////////////////////////////////////////

#ifndef _ATL_APARTMENT_THREADED
#define _ATL_APARTMENT_THREADED         // Select level of thread-
#endif // not Apartment Threaded        // safety for this server

#ifdef _DEBUG
#define _ATL_DEBUG_QI                   // Turn on ATL QI tracing
#endif // _DEBUG

#ifndef _ATL_NO_AUTOMATIC_NAMESPACE
#define _ATL_NO_AUTOMATIC_NAMESPACE     // Don't use the entire ATL
#endif // ! _ATL_NO_AUTOMATIC_NAMESPACE // namespace

#ifndef _ATL_STATIC_REGISTRY
#define _ATL_STATIC_REGISTRY            // Static link to the ATL lib
#endif // ! _ATL_STATIC_REGISTRY

#ifndef _CRT_SECURE_NO_DEPRECATE        // Shut the compiler up about
#define _CRT_SECURE_NO_DEPRECATE        // old CRT string routines
#endif // ! _CRT_SECURE_NO_DEPRECATE

#ifndef STRICT
#define STRICT                          // Turn on strict(er) type-
#endif // ! STRICT                      // checking in Windows headers

#ifndef ATLBASE_H_INCLUDED
#include <atlbase.h>                    // Core ATL classes (that don't
#define ATLBASE_H_INCLUDED              // depend on _Module)
#endif // not <atlbase.h>

#ifndef ATLCOM_H_INCLUDED
#include <atlcom.h>                     // ATL support for building COM
#define ATLCOM_H_INCLUDED               // servers
#endif // not <atlcom.h>

#ifndef ATLCTL_H_INCLUDED
#include <atlctl.h>                     // ATL control support
#define ATLCTL_H_INCLUDED
#endif // not <atlctl.h>

using namespace ATL;                    // Normally I'd never put a
										// using declaration in a
										// header; this seems to be
										// commonly used, however.

#ifndef STRING_INCLUDED
#include <string>                       // For class std::wstring
#define STRING_INCLUDED
#endif // not <string>

#ifndef ADDAUTO_H_INCLUDED
#include <ObjModel\ADDAUTO.H>           // DevStudio 6.0 AddIn
#define ADDAUTO_H_INCLUDED              // interfaces
#endif // not ADDAUTO_H_INCLUDED

#ifndef ADDGUID_H_INCLUDED
#include <ObjModel\ADDGUID.H>           // DevStudio 6.0 Addin UUIDs
#define ADDGUID_H_INCLUDED
#endif // not ADDGUID_H_INCLUDED

#ifndef APPGUID_H_INCLUDED
#include <ObjModel\APPGUID.H>           // DevStudio 6.0 Object model
#define APPGUID_H_INCLUDED              // UUIDs
#endif // not APPGUID_H_INCLUDED

#pragma warning (push, 3)               // It's just easier to dial the
										// compiler warning level down
										// for these #imports (since I
										// can't do anything about
										// them, anyway).
// For interface IDTExtensibility2
// C:\Program Files\Common Files\DESIGNER\MSADDNDR.DLL
#import "libid:AC0714F2-3D04-11D1-AE7D-00A0C90F26F4" version("1.0")      \
	lcid("0") raw_interfaces_only named_guids

// For Visual Studio Command Bar interfaces
// C:\Program Files\Common Files\Microsoft Shared\MSEnv\vsmso.olb
#import "libid:1CBA492E-7263-47BB-87FE-639000619B15" version("8.0")      \
	lcid("0") raw_interfaces_only named_guids

// For the DTE interface
// C:\Program Files\Common Files\Microsoft Shared\MSEnv\dte80a.olb
#import "libid:80cc9f66-e7d8-4ddd-85b6-d9e6cd0e93e2" version("8.0")      \
	lcid("0") raw_interfaces_only named_guids                            \
	rename("FindText",    "dte80aFindText")                              \
	rename("GetObject",   "dte80aGetObject")                             \
	rename("ReplaceText", "dte80aReplaceText")                           \
	rename("SearchPath",  "dte80aSearchPath")

// For the DTE80 interface
// C:\Program Files\Common Files\Microsoft Shared\MSEnv\dte80.olb
#import "libid:1A31287A-4D7D-413e-8E32-3B374931BD89" version("8.0")      \
	lcid("0") raw_interfaces_only named_guids

// For the MSO object model
// C:\Program Files\Common Files\Microsoft Shared\OFFICE11\MSO.DLL
#import "libid:2DF8D04C-5BFA-101B-BDE5-00AA0044DE52" version("2.3")      \
	lcid("0") raw_interfaces_only /*named_guids*/                        \
	rename("RGB",                "msoRGB")                               \
	rename("DocumentProperties", "msoDocumentProperties")

#pragma warning (pop)

namespace AddInDO = AddInDesignerObjects;               // These names are
namespace MSVSCBs = Microsoft_VisualStudio_CommandBars; // waaaaaaay too
														// long... create
														// aliases.

const UINT INCVERSION_DEBUG_LOG_LEVEL = 4U;             // This determines
														// the ATLTRACE
														// verbosity for
														// debug builds.

/**
 * \defgroup cmdbar_defns CommandBar Definitions
 *
 * \brief Control management of control bars in the host app
 *
 *
 * There are a few ways for an AddIn to setup command bars in its host
 * application. #defines in this group will control how the IncVersion
 * AddIn handles this.
 *
 *
 */
 
/**
 * \brief Use temporary command bars
 *
 * \ingroup cmdbar_defns
 *
 *
 * Set INCVERSION_COMMAND_BAR_STYLE to INCVERSION_COMMAND_BAR_TEMPORARY to
 * use "temporary" command bars.  These are created when the connection
 * mode is ext_cm_Startup or ext_cm_AfterStartup through
 * CommandBars::Add.  They will be removed by calling the Delete method
 * on the command bar itself when the AddIn is unloaded.
 *
 * This can be irritating because the command bar is re-created every
 * time the AddIn is loaded, even when the user has chosen to delete it
 * or hide it.  However, I've found this approach to be less likely to
 * leave the command bar laying around after the AddIn has been unloaded
 * and/or un-installed.
 *
 *
 */

#define INCVERSION_COMMAND_BAR_TEMPORARY     ( 1 )

/**
 * \brief Use permanent command bars
 *
 * \ingroup cmdbar_defns
 *
 *
 * Set INCVERSION_COMMAND_BAR_STYLE to INCVERSION_COMMAND_BAR_PERMANENT to
 * use "permanent" command  bars.  These will be created with the
 * connection mode is ext_cm_UISetup (through Commands::AddCommandBar),
 * and are never programmatically deleted.
 *
 * These are nice because they'll respect the user's choices to delete
 * or hide the command bar.  It also seems to be in keeping with the
 * object model's intent, as I read it in the MSDN docs.  For instance,
 * the choice to keep the command bar around even if the user unloads it
 * via the AddIn Manager seems intentional. However, the AddIn author
 * is now responsible for deleting the thing separately during an
 * un-install.  I've also seen situations where a partial un-install
 * left the command bar present & un-deletable short of resetting the
 * IDE.
 *
 *
 */
 
#define INCVERSION_COMMAND_BAR_PERMANENT     ( 2 )

/**
 * \brief Use permanent command bars
 *
 * \ingroup cmdbar_defns
 *
 *
 * Set INCVERSION_COMMAND_BAR_STYLE to
 * INCVERSION_COMMAND_BAR_SEMIPERMANENT to use "permanent" command bars,
 * but have the AddIn remove them when the user manually unloads the
 * AddIn through the AddIn manager.  Think of this as a compromise
 * between the other two styles.
 *
 *
 */

#define INCVERSION_COMMAND_BAR_SEMIPERMANENT ( 3 )

/**
 * \brief By default, use permanent toolbars
 *
 * \ingroup cmdbar_defns
 *
 *
 */
 
//#define INCVERSION_COMMAND_BAR_STYLE INCVERSION_COMMAND_BAR_TEMPORARY
#define INCVERSION_COMMAND_BAR_STYLE INCVERSION_COMMAND_BAR_PERMANENT
//#define INCVERSION_COMMAND_BAR_STYLE INCVERSION_COMMAND_BAR_SEMIPERMANENT

#define HANDLE_COM_ERROR(clsid, iid, hr)                             \
	catch (const _com_error &ex)                                     \
{                                                                    \
	LPCTSTR lpszMsg = NULL;                                          \
	_bstr_t bstrDsc = ex.Description();                              \
	if (0 != bstrDsc.length()) lpszMsg = bstrDsc;                    \
	else                       lpszMsg = ex.ErrorMessage();          \
	hr = AtlReportError((clsid), lpszMsg, (iid), ex.Error());        \
}

#define HANDLE_EXCEPTION(clsid, iid, hr)                             \
	catch (const std::exception &ex)                                 \
{                                                                    \
	hr = AtlReportError((clsid), ex.what(), (iid), E_FAIL);          \
}

// Local Variables:
// fill-column: 72
// comment-column: 41
// indent-tabs-mode: nil
// show-trailing-whitespace: t
// End:

#endif // STDAFX_H_10C3F2AB_C971_462D_AE43_8D659E613A34

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United Kingdom United Kingdom
Ok, it's about time I updated this profile. I still live near 'Beastly' Eastleigh in Hampshire, England. However I have recently been granted a permamant migration visa to Australia - so if you're a potential employer from down under and like the look of me, please get in touch.
Still married - just, still with just a son and daughter. But they are now 8 and 7 resp and when together they have the energy of a nuclear bomb.
I worked at Teleca UK for over 8.5 years (but have now moved to TikitTFB) and have done loads of different things. Heavily involved with MFC, SQL, C#, The latest is ASP.NET with C# and Javascript. Moving away from Trolltech Qt3 and 4.
Jordan.

Comments and Discussions