/**
* \file IncVersion.cpp
*
* \brief DLL Exports for IncVersion.dll
*
* $Id: IncVersion.cpp, v1.1.1.1 2006/09/24 23:12:30 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.
*
*
*/
////////////////////////////////////////////////////////////////////////////
// Modified by Jordan Walters, 01.03.2008 for multi-IDE version increment //
////////////////////////////////////////////////////////////////////////////
#include "stdafx.h" // Pre-compiled header
#include "resource.h" // Resource definitions
#include "AddIn.h" // For class CAddIn
#include "IncVersion.h" // MIDL-generated COM bindings
#include <initguid.h> // Toggle the 'DEFINE_GUID' macro to
// definition, rather than just
// declaration...
// {C0002F81-AE2E-11CF-AD70-00A0C9304965}
DEFINE_GUID(IID_IDSAddIn,
0xc0002f81, 0xae2e, 0x11cf, 0xad, 0x7, 0x0, 0xa0, 0xc9, 0x3, 0x49, 0x65);
// {8EA3F900-4A9F-11cf-8E4E-00AA004254C4}
DEFINE_GUID(IID_IApplicationEvents,
0x8ea3f900, 0x4a9f, 0x11cf, 0x8e, 0x4e, 0x0, 0xaa, 0x0, 0x42, 0x54, 0xc4);
CIncVersionModule _AtlModule;
CTraceCategory atlTraceIncVersion("IncVersion", 1);
// DLL Entry Point
extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance,
DWORD dwReason,
LPVOID lpReserved)
{
if (DLL_PROCESS_ATTACH == dwReason)
{
hInstance;
#ifdef _DEBUG
CTrace::s_trace.SetLevel(INCVERSION_DEBUG_LOG_LEVEL);
ATLTRACE2(atlTraceCOM, 3, "IncVersion.dll loading (0x%08x).\n", hInstance);
#endif // _DEBUG
}
else if (DLL_PROCESS_DETACH == dwReason)
{
ATLTRACE2(atlTraceCOM, 3, "IncVersion.dll un-loading.\n");
}
return _AtlModule.DllMain(dwReason, lpReserved);
}
// Used to determine whether the DLL can be unloaded by OLE
STDAPI DllCanUnloadNow(void)
{
ATLTRACE2(atlTraceCOM, 3, "IncVersion.dll unloading\n");
return _AtlModule.DllCanUnloadNow();
}
// Returns a class factory to create an object of the requested type
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
}
/**
* \brief Adds entries to the system registry
*
*
* \return S_OK on success, a stock error code otherwise
*
*
* This method will register our COM component (CoAddIn), as well as
* handling self-registration for our target hosts.
*
*
*/
STDAPI DllRegisterServer()
{
HRESULT hr = S_OK;
hr = _AtlModule.DllRegisterServer();
if (FAILED(hr)) return hr;
CRegKey hKey;
LONG lStatus = hKey.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft")
_T("\\DevStudio\\6.0\\AddIns"));
if (ERROR_SUCCESS == lStatus)
{
ATLTRACE2(atlTraceRegistrar, 3, "This server will be registered as"
" a DevStudio 6 AddIn.");
hr = _AtlModule.UpdateRegistryFromResourceS(IDR_DEVSTUDIO, TRUE);
if (FAILED(hr)) return hr;
}
lStatus = hKey.Open(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Vi")
_T("sualStudio\\7.1\\AddIns"));
if (ERROR_SUCCESS == lStatus)
{
ATLTRACE2(atlTraceRegistrar, 3, "This server will be registered as"
" a Visual Studio 2003 AddIn.");
hr = _AtlModule.UpdateRegistryFromResourceS(IDR_VS2003, TRUE);
if (FAILED(hr)) return hr;
}
lStatus = hKey.Open(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Vi")
_T("sualStudio\\8.0\\AddIns"));
if (ERROR_SUCCESS == lStatus)
{
ATLTRACE2(atlTraceRegistrar, 3, "This server will be registered as"
" a Visual Studio 2005 AddIn.");
hr = _AtlModule.UpdateRegistryFromResourceS(IDR_VS2005, TRUE);
if (FAILED(hr)) return hr;
}
// Later: Add other applications here...
return hr;
}
// DllUnregisterServer - Removes entries from the system registry
STDAPI DllUnregisterServer(void)
{
HRESULT hr = S_OK;
_AtlModule.DllUnregisterServer();
_AtlModule.UpdateRegistryFromResourceS(IDR_DEVSTUDIO, FALSE);
_AtlModule.UpdateRegistryFromResourceS(IDR_VS2003, FALSE);
_AtlModule.UpdateRegistryFromResourceS(IDR_VS2005, FALSE);
// Later: Add other applications here...
CRegKey hKey;
LONG lStatus = hKey.Open(HKEY_CURRENT_USER, SOFTWARE);
if (ERROR_SUCCESS == lStatus)
{
lStatus = hKey.Open(hKey, KITTYLION);
if (ERROR_SUCCESS == lStatus)
{
hKey.RecurseDeleteKey(INCVERSION);
}
}
return hr;
}
// Local Variables:
// fill-column: 72
// indent-tabs-mode: nil
// show-trailing-whitespace: t
// End:
// IncVersion.cpp ends here.