GME
13
|
00001 // DecoratorApp.cpp : Implementation of DLL Exports. 00002 00003 00004 // Note: Proxy/Stub Information 00005 // To build a separate proxy/stub DLL, 00006 // run nmake -f DecoratorAppps.mk in the project directory. 00007 00008 #include "stdafx.h" 00009 #include <initguid.h> 00010 #include "Resource.h" 00011 #include "Gme.h" 00012 #include "DecoratorConfig.h" 00013 #include "DecoratorLib.h" 00014 #include "DecoratorLib_i.c" 00015 #include "AnnotatorDecoratorImpl.h" 00016 00017 00018 CComModule _Module; 00019 00020 BEGIN_OBJECT_MAP(ObjectMap) 00021 OBJECT_ENTRY(CLSID_AnnotatorDecorator, CAnnotatorDecoratorImpl) 00022 END_OBJECT_MAP() 00023 00024 class CDecoratorApp : public CWinApp 00025 { 00026 public: 00027 00028 // Overrides 00029 // ClassWizard generated virtual function overrides 00030 //{{AFX_VIRTUAL(CDecoratorApp) 00031 public: 00032 virtual BOOL InitInstance(); 00033 virtual int ExitInstance(); 00034 //}}AFX_VIRTUAL 00035 00036 //{{AFX_MSG(CDecoratorApp) 00037 // NOTE - the ClassWizard will add and remove member functions here. 00038 // DO NOT EDIT what you see in these blocks of generated code ! 00039 //}}AFX_MSG 00040 DECLARE_MESSAGE_MAP() 00041 }; 00042 00043 BEGIN_MESSAGE_MAP(CDecoratorApp, CWinApp) 00044 //{{AFX_MSG_MAP(CDecoratorApp) 00045 // NOTE - the ClassWizard will add and remove mapping macros here. 00046 // DO NOT EDIT what you see in these blocks of generated code! 00047 //}}AFX_MSG_MAP 00048 END_MESSAGE_MAP() 00049 00050 CDecoratorApp theApp; 00051 00052 BOOL CDecoratorApp::InitInstance() 00053 { 00054 #if _MSC_VER < 1700 00055 // See MSDN example code for CWinApp::InitInstance: http://msdn.microsoft.com/en-us/library/ae6yx0z0.aspx 00056 // MFC module state handling code is changed with VC80. 00057 // We follow the Microsoft's suggested way, but in case of any trouble the set the 00058 // HKCU\Software\GME\AfxSetAmbientActCtxMod key to 0 00059 UINT uAfxSetAmbientActCtxMod = 1; 00060 HKEY hKey; 00061 if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\GME\\"), 00062 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) 00063 { 00064 TCHAR szData[128]; 00065 DWORD dwKeyDataType; 00066 DWORD dwDataBufSize = sizeof(szData)/sizeof(TCHAR); 00067 00068 if (RegQueryValueEx(hKey, _T("AfxSetAmbientActCtxMod"), NULL, &dwKeyDataType, 00069 (LPBYTE) &szData, &dwDataBufSize) == ERROR_SUCCESS) 00070 { 00071 uAfxSetAmbientActCtxMod = _tcstoul(szData, NULL, 10); 00072 } 00073 00074 RegCloseKey(hKey); 00075 } 00076 if (uAfxSetAmbientActCtxMod != 0) 00077 { 00078 AfxSetAmbientActCtx(FALSE); 00079 } 00080 #endif 00081 00082 _Module.Init(ObjectMap, m_hInstance, &LIBID_DecoratorLib); 00083 return CWinApp::InitInstance(); 00084 } 00085 00086 int CDecoratorApp::ExitInstance() 00087 { 00088 _Module.Term(); 00089 return CWinApp::ExitInstance(); 00090 } 00091 00093 // Used to determine whether the DLL can be unloaded by OLE 00094 00095 STDAPI DllCanUnloadNow(void) 00096 { 00097 AFX_MANAGE_STATE(AfxGetStaticModuleState()); 00098 00099 return (AfxDllCanUnloadNow()==S_OK && _Module.GetLockCount()==0) ? S_OK : S_FALSE; 00100 } 00101 00103 // Returns a class factory to create an object of the requested type 00104 00105 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) 00106 { 00107 AFX_MANAGE_STATE(AfxGetStaticModuleState());//z 00108 return _Module.GetClassObject(rclsid, riid, ppv); 00109 } 00110 00112 // DllRegisterServer - Adds entries to the system registry 00113 00114 STDAPI DllRegisterServer(void) 00115 { 00116 AFX_MANAGE_STATE(AfxGetStaticModuleState());//z 00117 00118 _ATL_REGMAP_ENTRY regMap[] = { 00119 {CONSTOLESTR("COCLASS_PROGID"), CONSTOLESTR(COCLASS_PROGID)}, 00120 {CONSTOLESTR("COCLASS_NAME"), CONSTOLESTR(COCLASS_NAME)}, 00121 {CONSTOLESTR("COCLASS_UUID"), CONSTOLESTR(COCLASS_UUID)}, 00122 {CONSTOLESTR("TYPELIB_UUID"), CONSTOLESTR(TYPELIB_UUID)}, 00123 {0, 0} 00124 }; 00125 HRESULT hr = _Module.UpdateRegistryFromResourceD( IDR_DECORATOR, TRUE, regMap ); 00126 00127 /* if ( SUCCEEDED( hr ) ) //do not use this ! 00128 { 00129 // registers object, typelib and all 00130 // interfaces in typelib 00131 hr = _Module.RegisterServer(TRUE); 00132 } 00133 */ 00134 return hr; 00135 } 00136 00138 // DllUnregisterServer - Removes entries from the system registry 00139 00140 STDAPI DllUnregisterServer(void) 00141 { 00142 AFX_MANAGE_STATE(AfxGetStaticModuleState());//z 00143 00144 _ATL_REGMAP_ENTRY regMap[] = { 00145 {CONSTOLESTR("COCLASS_PROGID"), CONSTOLESTR(COCLASS_PROGID)}, 00146 {CONSTOLESTR("COCLASS_NAME"), CONSTOLESTR(COCLASS_NAME)}, 00147 {CONSTOLESTR("COCLASS_UUID"), CONSTOLESTR(COCLASS_UUID)}, 00148 {CONSTOLESTR("TYPELIB_UUID"), CONSTOLESTR(TYPELIB_UUID)}, 00149 {0, 0} 00150 }; 00151 HRESULT hr = _Module.UpdateRegistryFromResourceD( IDR_DECORATOR, FALSE, regMap ); 00152 00153 /* if ( SUCCEEDED( hr ) ) //do not use this ! 00154 { 00155 // registers object, typelib and all 00156 // interfaces in typelib 00157 hr = _Module.UnregisterServer(TRUE); 00158 } 00159 */ 00160 return hr; 00161 } 00162 00163