1 // VisVim.cpp : Defines the initialization routines for the DLL.
13 static char THIS_FILE
[] = __FILE__
;
19 BEGIN_OBJECT_MAP (ObjectMap
)
20 OBJECT_ENTRY (CLSID_DSAddIn
, CDSAddIn
)
23 class CVisVimApp
: public CWinApp
28 //{{AFX_VIRTUAL(CVisVimApp)
30 virtual BOOL
InitInstance ();
31 virtual int ExitInstance ();
34 //{{AFX_MSG(CVisVimApp)
36 DECLARE_MESSAGE_MAP ()
39 BEGIN_MESSAGE_MAP (CVisVimApp
, CWinApp
)
40 //{{AFX_MSG_MAP(CVisVimApp)
44 // The one and only CVisVimApp object
47 CVisVimApp::CVisVimApp ()
51 BOOL
CVisVimApp::InitInstance ()
53 _Module
.Init (ObjectMap
, m_hInstance
);
54 return CWinApp::InitInstance ();
57 int CVisVimApp::ExitInstance ()
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)
79 // By exporting DllRegisterServer, you can use regsvr32.exe
81 STDAPI
DllRegisterServer (void)
83 AFX_MANAGE_STATE (AfxGetStaticModuleState ());
86 // Registers object, typelib and all interfaces in typelib
87 hRes
= _Module
.RegisterServer (TRUE
);
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;
96 _ATL_OBJMAP_ENTRY
*pEntry
= _Module
.m_pObjMap
;
98 LONG lRes
= key
.Open (HKEY_CLASSES_ROOT
, _T ("CLSID"));
100 if (lRes
== ERROR_SUCCESS
)
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
);
126 // DllUnregisterServer - Removes entries from the system registry
128 STDAPI
DllUnregisterServer (void)
130 AFX_MANAGE_STATE (AfxGetStaticModuleState ());
133 _Module
.UnregisterServer ();
140 // GetLastErrorDescription is used in the implementation of the VERIFY_OK
141 // macro, defined in stdafx.h.
145 void GetLastErrorDescription (CComBSTR
& bstr
)
147 CComPtr
< IErrorInfo
> pErrorInfo
;
148 if (GetErrorInfo (0, &pErrorInfo
) == S_OK
)
149 pErrorInfo
->GetDescription (&bstr
);