// mbEasySend.cpp : Defines the initialization routines for the DLL.
|
//
|
|
#include "stdafx.h"
|
#include "mbEasySend.h"
|
#include <initguid.h>
|
#include "mbEasySend_i.c"
|
|
#ifdef _DEBUG
|
#define new DEBUG_NEW
|
#endif
|
|
//
|
//TODO: If this DLL is dynamically linked against the MFC DLLs,
|
// any functions exported from this DLL which call into
|
// MFC must have the AFX_MANAGE_STATE macro added at the
|
// very beginning of the function.
|
//
|
// For example:
|
//
|
// extern "C" BOOL PASCAL EXPORT ExportedFunction()
|
// {
|
// AFX_MANAGE_STATE(AfxGetStaticModuleState());
|
// // normal function body here
|
// }
|
//
|
// It is very important that this macro appear in each
|
// function, prior to any calls into MFC. This means that
|
// it must appear as the first statement within the
|
// function, even before any object variable declarations
|
// as their constructors may generate calls into the MFC
|
// DLL.
|
//
|
// Please see MFC Technical Notes 33 and 58 for additional
|
// details.
|
//
|
|
// CmbEasySendApp
|
|
|
class CmbEasySendModule :
|
public ATL::CAtlMfcModule
|
{
|
public:
|
DECLARE_LIBID(LIBID_mbEasySendLib);
|
DECLARE_REGISTRY_APPID_RESOURCEID(IDR_MBEASYSEND, "{B2B8AAF9-1D75-408B-9052-1B1A9E58129C}");};
|
|
CmbEasySendModule _AtlModule;
|
|
BEGIN_MESSAGE_MAP(CmbEasySendApp, CWinApp)
|
END_MESSAGE_MAP()
|
|
|
// CmbEasySendApp construction
|
|
CmbEasySendApp::CmbEasySendApp()
|
{
|
// TODO: add construction code here,
|
// Place all significant initialization in InitInstance
|
}
|
|
|
// The one and only CmbEasySendApp object
|
|
CmbEasySendApp theApp;
|
|
|
// CmbEasySendApp initialization
|
|
BOOL CmbEasySendApp::InitInstance()
|
{
|
COleObjectFactory::RegisterAll();
|
|
CWinApp::InitInstance();
|
|
return TRUE;
|
}
|
|
// DllCanUnloadNow - Allows COM to unload DLL
|
#if !defined(_WIN32_WCE) && !defined(_AMD64_) && !defined(_IA64_)
|
#pragma comment(linker, "/EXPORT:DllCanUnloadNow=_DllCanUnloadNow@0,PRIVATE")
|
#pragma comment(linker, "/EXPORT:DllGetClassObject=_DllGetClassObject@12,PRIVATE")
|
#pragma comment(linker, "/EXPORT:DllRegisterServer=_DllRegisterServer@0,PRIVATE")
|
#pragma comment(linker, "/EXPORT:DllUnregisterServer=_DllUnregisterServer@0,PRIVATE")
|
#else
|
#if defined(_X86_) || defined(_SHX_)
|
#pragma comment(linker, "/EXPORT:DllCanUnloadNow=_DllCanUnloadNow,PRIVATE")
|
#pragma comment(linker, "/EXPORT:DllGetClassObject=_DllGetClassObject,PRIVATE")
|
#pragma comment(linker, "/EXPORT:DllRegisterServer=_DllRegisterServer,PRIVATE")
|
#pragma comment(linker, "/EXPORT:DllUnregisterServer=_DllUnregisterServer,PRIVATE")
|
#else
|
#pragma comment(linker, "/EXPORT:DllCanUnloadNow,PRIVATE")
|
#pragma comment(linker, "/EXPORT:DllGetClassObject,PRIVATE")
|
#pragma comment(linker, "/EXPORT:DllRegisterServer,PRIVATE")
|
#pragma comment(linker, "/EXPORT:DllUnregisterServer,PRIVATE")
|
#endif // (_X86_)||(_SHX_)
|
#endif // !_WIN32_WCE && !_AMD64_ && !_IA64_
|
|
STDAPI DllCanUnloadNow(void)
|
{
|
AFX_MANAGE_STATE(AfxGetStaticModuleState());
|
if (_AtlModule.GetLockCount() > 0)
|
return S_FALSE;
|
return S_OK;
|
}
|
|
// DllGetClassObject - Returns class factory
|
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
|
{
|
AFX_MANAGE_STATE(AfxGetStaticModuleState());
|
if (S_OK == _AtlModule.GetClassObject(rclsid, riid, ppv))
|
return S_OK;
|
return AfxDllGetClassObject(rclsid, riid, ppv);
|
}
|
|
// DllRegisterServer - Adds entries to the system registry
|
STDAPI DllRegisterServer(void)
|
{
|
AFX_MANAGE_STATE(AfxGetStaticModuleState());
|
if ( 0 == (GetVersion() & 0x80000000UL) )
|
{
|
CRegKey reg;
|
LONG lRet;
|
|
lRet = reg.Open ( HKEY_LOCAL_MACHINE,
|
_T("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"),
|
KEY_SET_VALUE );
|
|
if ( ERROR_SUCCESS != lRet )
|
return E_ACCESSDENIED;
|
|
lRet = reg.SetValue ( _T("MBC EasySend shell extension"),
|
_T("{A8FF42A6-681E-4AA6-B914-D8D2D6A20F78}") );
|
if ( ERROR_SUCCESS != lRet )
|
return E_ACCESSDENIED;
|
}
|
_AtlModule.UpdateRegistryAppId(TRUE);
|
HRESULT hRes2 = _AtlModule.RegisterServer(TRUE);
|
if (hRes2 != S_OK)
|
return hRes2;
|
if (!COleObjectFactory::UpdateRegistryAll(TRUE))
|
return ResultFromScode(SELFREG_E_CLASS);
|
return S_OK;
|
}
|
|
// DllUnregisterServer - Removes entries from the system registry
|
STDAPI DllUnregisterServer(void)
|
{
|
AFX_MANAGE_STATE(AfxGetStaticModuleState());
|
if ( 0 == (GetVersion() & 0x80000000UL) )
|
{
|
CRegKey reg;
|
LONG lRet;
|
|
lRet = reg.Open ( HKEY_LOCAL_MACHINE,
|
_T("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"),
|
KEY_SET_VALUE );
|
|
if ( ERROR_SUCCESS == lRet )
|
{
|
lRet = reg.DeleteValue ( _T("{A8FF42A6-681E-4AA6-B914-D8D2D6A20F78}") );
|
}
|
}
|
_AtlModule.UpdateRegistryAppId(FALSE);
|
HRESULT hRes2 = _AtlModule.UnregisterServer(TRUE);
|
if (hRes2 != S_OK)
|
return hRes2;
|
if (!COleObjectFactory::UpdateRegistryAll(FALSE))
|
return ResultFromScode(SELFREG_E_CLASS);
|
return S_OK;
|
}
|