Changed DiffText and Constant highlight groups
[MacVim/jjgod.git] / src / VisVim / VisVim.cpp
blob222925a8975b9ce0fca46f4c960cad98dd9db0bc
1 // VisVim.cpp : Defines the initialization routines for the DLL.
2 //
4 #include "stdafx.h"
5 #include <initguid.h>
6 #include "VisVim.h"
7 #include "DSAddIn.h"
8 #include "Commands.h"
10 #ifdef _DEBUG
11 #define new DEBUG_NEW
12 #undef THIS_FILE
13 static char THIS_FILE[] = __FILE__;
15 #endif
17 CComModule _Module;
19 BEGIN_OBJECT_MAP (ObjectMap)
20 OBJECT_ENTRY (CLSID_DSAddIn, CDSAddIn)
21 END_OBJECT_MAP ()
23 class CVisVimApp : public CWinApp
25 public:
26 CVisVimApp ();
28 //{{AFX_VIRTUAL(CVisVimApp)
29 public:
30 virtual BOOL InitInstance ();
31 virtual int ExitInstance ();
32 //}}AFX_VIRTUAL
34 //{{AFX_MSG(CVisVimApp)
35 //}}AFX_MSG
36 DECLARE_MESSAGE_MAP ()
39 BEGIN_MESSAGE_MAP (CVisVimApp, CWinApp)
40 //{{AFX_MSG_MAP(CVisVimApp)
41 //}}AFX_MSG_MAP
42 END_MESSAGE_MAP ()
44 // The one and only CVisVimApp object
45 CVisVimApp theApp;
47 CVisVimApp::CVisVimApp ()
51 BOOL CVisVimApp::InitInstance ()
53 _Module.Init (ObjectMap, m_hInstance);
54 return CWinApp::InitInstance ();
57 int CVisVimApp::ExitInstance ()
59 _Module.Term ();
60 return CWinApp::ExitInstance ();
63 // Special entry points required for inproc servers
66 STDAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID * ppv)
68 AFX_MANAGE_STATE (AfxGetStaticModuleState ());
69 return _Module.GetClassObject (rclsid, riid, ppv);
72 STDAPI DllCanUnloadNow (void)
74 AFX_MANAGE_STATE (AfxGetStaticModuleState ());
75 return (AfxDllCanUnloadNow () == S_OK && _Module.GetLockCount () == 0)
76 ? S_OK : S_FALSE;
79 // By exporting DllRegisterServer, you can use regsvr32.exe
81 STDAPI DllRegisterServer (void)
83 AFX_MANAGE_STATE (AfxGetStaticModuleState ());
84 HRESULT hRes;
86 // Registers object, typelib and all interfaces in typelib
87 hRes = _Module.RegisterServer (TRUE);
88 if (FAILED (hRes))
89 // Hack: When this fails we might be a normal user, while the
90 // admin already registered the module. Returning S_OK then
91 // makes it work. When the module was never registered it
92 // will soon fail in another way.
93 // old code: return hRes;
94 return S_OK;
96 _ATL_OBJMAP_ENTRY *pEntry = _Module.m_pObjMap;
97 CRegKey key;
98 LONG lRes = key.Open (HKEY_CLASSES_ROOT, _T ("CLSID"));
100 if (lRes == ERROR_SUCCESS)
102 USES_CONVERSION;
103 LPOLESTR lpOleStr;
105 StringFromCLSID (*pEntry->pclsid, &lpOleStr);
106 LPTSTR lpsz = OLE2T (lpOleStr);
108 lRes = key.Open (key, lpsz);
109 if (lRes == ERROR_SUCCESS)
111 CString strDescription;
113 strDescription.LoadString (IDS_VISVIM_DESCRIPTION);
114 key.SetKeyValue (_T ("Description"), strDescription);
116 CoTaskMemFree (lpOleStr);
119 if (lRes != ERROR_SUCCESS)
120 hRes = HRESULT_FROM_WIN32 (lRes);
122 return hRes;
126 // DllUnregisterServer - Removes entries from the system registry
128 STDAPI DllUnregisterServer (void)
130 AFX_MANAGE_STATE (AfxGetStaticModuleState ());
132 HRESULT hRes = S_OK;
133 _Module.UnregisterServer ();
134 return hRes;
138 // Debugging support
140 // GetLastErrorDescription is used in the implementation of the VERIFY_OK
141 // macro, defined in stdafx.h.
143 #ifdef _DEBUG
145 void GetLastErrorDescription (CComBSTR & bstr)
147 CComPtr < IErrorInfo > pErrorInfo;
148 if (GetErrorInfo (0, &pErrorInfo) == S_OK)
149 pErrorInfo->GetDescription (&bstr);
152 #endif //_DEBUG