📄 addin.cpp
字号:
/************************************************************************
*
* Resource ID Organiser Add-In for Visual C++.NET
*
* (c) Copyright 2000-2002 by Anna-Jayne Metcalfe (resorg@annasplace.me.uk)
* All rights reserved.
*
************************************************************************
*
* Filename : AddIn.cpp
*
* Description : Implementation of DLL Exports
*
* Compiler : Microsoft Visual C++.NET 2002
*
* Target
* Environment : Windows 2000/XP
*
* NOTE:
*
* This software is provided "as is" free for personal use. All
* title and copyrights in and to the software, including but not
* limited to any images, text, etc. incorporated into it, are
* owned by Anna-Jayne Metcalfe, except where acknowledged otherwise.
*
* Your may freely to use this code in your own products, PROVIDED
* this notice is not removed or modified.
*
*
* Visit http://www.annasplace.me.uk/resorg for latest updates
*
************************************************************************
*
* MODIFICATION HISTORY:
*
* This is a controlled document. See project configuration
* control tool for latest version and full version history.
*
* $Archive: /Projects/AddIns/ResOrg/ResOrgNETAddIn/AddIn.cpp $
* $Revision: 7 $
* $Date: 22/10/05 16:40 $
* $Author: Anna $
*
* $History: AddIn.cpp $
*
* ***************** Version 7 *****************
* User: Anna Date: 22/10/05 Time: 16:40
* Updated in $/Projects/AddIns/ResOrg/ResOrgNETAddIn
* Moved CVc6AutomationHelper and CVc7AutomationHelper to the ResOrgAddIn
* and ResOrgNETAddIn projects respectively.
*
* ***************** Version 6 *****************
* User: Anna Date: 13/10/05 Time: 12:58
* Updated in $/Projects/AddIns/ResOrg/ResOrgNETAddIn
* DllRegisterServer() now sets all keys necessary to load the add-in,
* making installation far simpler and more robust.
*
* ***************** Version 5 *****************
* User: Anna Date: 25/11/02 Time: 15:27
* Updated in $/Projects/AddIns/ResOrg/ResOrgNETAddIn
* Changed website address in banner
*
* ***************** Version 4 *****************
* User: Anna Date: 22/10/02 Time: 14:18
* Updated in $/Projects/AddIns/ResOrg/ResOrgNETAddIn
* Changed name/email address (at last!)
*
* ***************** Version 3 *****************
* User: Andy Date: 5/08/02 Time: 13:36
* Updated in $/Projects/AddIns/ResOrg/ResOrgNETAddIn
* Removed commented out code
*
* ***************** Version 2 *****************
* User: Andy Date: 1/08/02 Time: 16:41
* Updated in $/Projects/AddIns/ResOrg/ResOrgNETAddIn
* Renamed the module to ResOrgNETAddIn
*
* ***************** Version 1 *****************
* User: Andy Date: 3/06/02 Time: 16:53
* Created in $/Projects/AddIns/ResOrg/ResOrgAddInVc7
*
* $Nokeywords: $
*
************************************************************************/
#include "StdAfx.h"
#include "ResOrgNETAddIn_Res.h"
#include "AddIn.h"
#define REG_BASE_KEY _T("SOFTWARE\\Microsoft\\VisualStudio\\%s\\AddIns\\ResOrgNetAddIn")
CAddInModule _Module;
static bool WriteStringValue(const CString& sKeyFmt,
const CString& sVisualStudioVer,
const CString& sValueName,
const CString& sValue)
{
CString sKeyName;
sKeyName.Format(sKeyFmt, sVisualStudioVer);
try
{
CRegKey regkey;
if (ERROR_SUCCESS == regkey.Open(HKEY_LOCAL_MACHINE, sKeyName, KEY_WRITE) )
{
if (ERROR_SUCCESS == regkey.SetStringValue(sValueName, sValue) )
{
return true;
}
}
}
catch (...)
{ //lint !e1775 (Info -- catch block does not catch any declared exception)
}
return false;
}
// DLL Entry Point
// NB NOT REQUIRED HERE AS IMPLEMENTED BY MFC
//extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
//{
// // get the current language version
// if (DLL_PROCESS_ATTACH == dwReason )
// {
// // TODO: is this required at start-up? if there are any failures?
// //LANGID langid = DetectLanguage();
//
// _Module.SetResourceInstance(hInstance);
// }
// return _Module.DllMain(dwReason, lpReserved);
//}
// Used to determine whether the DLL can be unloaded by OLE
STDAPI DllCanUnloadNow(void)
{
return _Module.DllCanUnloadNow();
}
// Returns a class factory to create an object of the requested type
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
return _Module.DllGetClassObject(rclsid, riid, ppv);
}
// DllRegisterServer - Adds entries to the system registry
STDAPI DllRegisterServer(void)
{
// registers object, typelib and all interfaces in typelib
HRESULT hr = _Module.DllRegisterServer();
// Now register the installation folder for the Satellite DLL
TCHAR szModule[_MAX_PATH];
::GetModuleFileName(_Module.GetResourceInstance(), szModule, _MAX_PATH);
CNGSplitPath split(szModule);
CString sInstallationFolder = split.GetDrive() + split.GetDirectory();
ATLASSERT(!sInstallationFolder.IsEmpty() );
if (!sInstallationFolder.IsEmpty() )
{
CString sRegPath;
WriteStringValue(REG_BASE_KEY, _T("7.0"), _T("SatelliteDllPath"), sInstallationFolder);
WriteStringValue(REG_BASE_KEY, _T("7.1"), _T("SatelliteDllPath"), sInstallationFolder);
WriteStringValue(REG_BASE_KEY, _T("8.0"), _T("SatelliteDllPath"), sInstallationFolder);
}
return hr;
}
// DllUnregisterServer - Removes entries from the system registry
STDAPI DllUnregisterServer(void)
{
HRESULT hr = _Module.DllUnregisterServer();
return hr;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -