GME  13
Search.cpp
Go to the documentation of this file.
00001 // Search.cpp : Implementation of CSearchApp and DLL registration.
00002 
00003 #include "stdafx.h"
00004 #include "Search.h"
00005 
00006 #ifdef _DEBUG
00007 #define new DEBUG_NEW
00008 #undef THIS_FILE
00009 static char THIS_FILE[] = __FILE__;
00010 #endif
00011 
00012 
00013 CSearchApp NEAR theApp;
00014 
00015 const GUID CDECL BASED_CODE _tlid =
00016                 { 0xe65eedef, 0x18b7, 0x4f67, { 0xbb, 0xc7, 0xe, 0x22, 0xd0, 0xd3, 0x4c, 0x28 } };
00017 const WORD _wVerMajor = 1;
00018 const WORD _wVerMinor = 0;
00019 
00020 
00022 // CSearchApp::InitInstance - DLL initialization
00023 
00024 BOOL CSearchApp::InitInstance()
00025 {
00026 #if _MSC_VER < 1700
00027         // See MSDN example code for CWinApp::InitInstance: http://msdn.microsoft.com/en-us/library/ae6yx0z0.aspx
00028         // MFC module state handling code is changed with VC80.
00029         // We follow the Microsoft's suggested way, but in case of any trouble the set the
00030         // HKCU\Software\GME\AfxSetAmbientActCtxMod key to 0
00031         UINT uAfxSetAmbientActCtxMod = 1;
00032         HKEY hKey;
00033         if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\GME\\"),
00034                                          0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
00035         {
00036                 TCHAR szData[128];
00037                 DWORD dwKeyDataType;
00038                 DWORD dwDataBufSize = sizeof(szData)/sizeof(TCHAR);
00039 
00040                 if (RegQueryValueEx(hKey, _T("AfxSetAmbientActCtxMod"), NULL, &dwKeyDataType,
00041                                                         (LPBYTE) &szData, &dwDataBufSize) == ERROR_SUCCESS)
00042                 {
00043                         uAfxSetAmbientActCtxMod = _tcstoul(szData, NULL, 10);
00044                 }
00045 
00046                 RegCloseKey(hKey);
00047         }
00048         if (uAfxSetAmbientActCtxMod != 0)
00049         {
00050                 AfxSetAmbientActCtx(FALSE);
00051         }
00052 #endif
00053 
00054         BOOL bInit = COleControlModule::InitInstance();
00055 
00056         if (bInit)
00057         {
00058                 SetRegistryKey(_T("GME\\GUI"));
00059         }
00060 
00061         return bInit;
00062 }
00063 
00064 
00066 // CSearchApp::ExitInstance - DLL termination
00067 
00068 int CSearchApp::ExitInstance()
00069 {
00070         // TODO: Add your own module termination code here.
00071 
00072         return COleControlModule::ExitInstance();
00073 }
00074 
00075 
00077 // DllRegisterServer - Adds entries to the system registry
00078 
00079 STDAPI DllRegisterServer(void)
00080 {
00081         AFX_MANAGE_STATE(_afxModuleAddrThis);
00082 
00083         if (!AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid))
00084                 return ResultFromScode(SELFREG_E_TYPELIB);
00085 
00086         if (!COleObjectFactoryEx::UpdateRegistryAll(TRUE))
00087                 return ResultFromScode(SELFREG_E_CLASS);
00088 
00089         return NOERROR;
00090 }
00091 
00092 
00094 // DllUnregisterServer - Removes entries from the system registry
00095 
00096 STDAPI DllUnregisterServer(void)
00097 {
00098         AFX_MANAGE_STATE(_afxModuleAddrThis);
00099 
00100         if (!AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor))
00101                 return ResultFromScode(SELFREG_E_TYPELIB);
00102 
00103         if (!COleObjectFactoryEx::UpdateRegistryAll(FALSE))
00104                 return ResultFromScode(SELFREG_E_CLASS);
00105 
00106         return NOERROR;
00107 }