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