comparison src/if_ole.cpp @ 380:da6e29ecd0fc

updated for version 7.0099
author vimboss
date Fri, 01 Jul 2005 22:31:55 +0000
parents a18bd33b8ea9
children f92bb1845823
comparison
equal deleted inserted replaced
379:d6d6ca943713 380:da6e29ecd0fc
76 76
77 class CVim : public IVim 77 class CVim : public IVim
78 { 78 {
79 public: 79 public:
80 ~CVim(); 80 ~CVim();
81 static CVim *Create(int* pbDoRestart); 81 static CVim *Create(int *pbDoRestart);
82 82
83 // IUnknown members 83 // IUnknown members
84 STDMETHOD(QueryInterface)(REFIID riid, void ** ppv); 84 STDMETHOD(QueryInterface)(REFIID riid, void ** ppv);
85 STDMETHOD_(unsigned long, AddRef)(void); 85 STDMETHOD_(unsigned long, AddRef)(void);
86 STDMETHOD_(unsigned long, Release)(void); 86 STDMETHOD_(unsigned long, Release)(void);
87 87
88 // IDispatch members 88 // IDispatch members
89 STDMETHOD(GetTypeInfoCount)(UINT *pCount); 89 STDMETHOD(GetTypeInfoCount)(UINT *pCount);
90 STDMETHOD(GetTypeInfo)(UINT iTypeInfo, LCID, ITypeInfo **ppITypeInfo); 90 STDMETHOD(GetTypeInfo)(UINT iTypeInfo, LCID, ITypeInfo **ppITypeInfo);
91 STDMETHOD(GetIDsOfNames)(const IID& iid, OLECHAR** names, UINT n, LCID, DISPID *dispids); 91 STDMETHOD(GetIDsOfNames)(const IID &iid, OLECHAR **names, UINT n, LCID, DISPID *dispids);
92 STDMETHOD(Invoke)(DISPID member, const IID& iid, LCID, WORD flags, DISPPARAMS *dispparams, VARIANT *result, EXCEPINFO *excepinfo, UINT *argerr); 92 STDMETHOD(Invoke)(DISPID member, const IID &iid, LCID, WORD flags, DISPPARAMS *dispparams, VARIANT *result, EXCEPINFO *excepinfo, UINT *argerr);
93 93
94 // IVim members 94 // IVim members
95 STDMETHOD(SendKeys)(BSTR keys); 95 STDMETHOD(SendKeys)(BSTR keys);
96 STDMETHOD(Eval)(BSTR expr, BSTR *result); 96 STDMETHOD(Eval)(BSTR expr, BSTR *result);
97 STDMETHOD(SetForeground)(void); 97 STDMETHOD(SetForeground)(void);
98 STDMETHOD(GetHwnd)(UINT* result); 98 STDMETHOD(GetHwnd)(UINT *result);
99 99
100 private: 100 private:
101 // Constructor is private - create using CVim::Create() 101 // Constructor is private - create using CVim::Create()
102 CVim() : ref(0), typeinfo(0) {}; 102 CVim() : ref(0), typeinfo(0) {};
103 103
110 110
111 /* Implementation 111 /* Implementation
112 * -------------- 112 * --------------
113 */ 113 */
114 114
115 CVim *CVim::Create(int* pbDoRestart) 115 CVim *CVim::Create(int *pbDoRestart)
116 { 116 {
117 HRESULT hr; 117 HRESULT hr;
118 CVim *me = 0; 118 CVim *me = 0;
119 ITypeLib *typelib = 0; 119 ITypeLib *typelib = 0;
120 ITypeInfo *typeinfo = 0; 120 ITypeInfo *typeinfo = 0;
185 185
186 CVim::~CVim() 186 CVim::~CVim()
187 { 187 {
188 if (typeinfo && vim_parent_hwnd == NULL) 188 if (typeinfo && vim_parent_hwnd == NULL)
189 typeinfo->Release(); 189 typeinfo->Release();
190 typeinfo = 0;
190 } 191 }
191 192
192 STDMETHODIMP 193 STDMETHODIMP
193 CVim::QueryInterface(REFIID riid, void **ppv) 194 CVim::QueryInterface(REFIID riid, void **ppv)
194 { 195 {
240 return S_OK; 241 return S_OK;
241 } 242 }
242 243
243 STDMETHODIMP 244 STDMETHODIMP
244 CVim::GetIDsOfNames( 245 CVim::GetIDsOfNames(
245 const IID& iid, 246 const IID &iid,
246 OLECHAR** names, 247 OLECHAR **names,
247 UINT n, 248 UINT n,
248 LCID, 249 LCID,
249 DISPID *dispids) 250 DISPID *dispids)
250 { 251 {
251 if (iid != IID_NULL) 252 if (iid != IID_NULL)
255 } 256 }
256 257
257 STDMETHODIMP 258 STDMETHODIMP
258 CVim::Invoke( 259 CVim::Invoke(
259 DISPID member, 260 DISPID member,
260 const IID& iid, 261 const IID &iid,
261 LCID, 262 LCID,
262 WORD flags, 263 WORD flags,
263 DISPPARAMS *dispparams, 264 DISPPARAMS *dispparams,
264 VARIANT *result, 265 VARIANT *result,
265 EXCEPINFO *excepinfo, 266 EXCEPINFO *excepinfo,
273 member, flags, dispparams, 274 member, flags, dispparams,
274 result, excepinfo, argerr); 275 result, excepinfo, argerr);
275 } 276 }
276 277
277 STDMETHODIMP 278 STDMETHODIMP
278 CVim::GetHwnd(UINT* result) 279 CVim::GetHwnd(UINT *result)
279 { 280 {
280 *result = (UINT) s_hwnd; 281 *result = (UINT) s_hwnd;
281 return S_OK; 282 return S_OK;
282 } 283 }
283 284
484 /***************************************************************************** 485 /*****************************************************************************
485 4. Registry manipulation code 486 4. Registry manipulation code
486 *****************************************************************************/ 487 *****************************************************************************/
487 488
488 // Internal use only 489 // Internal use only
489 static void SetKeyAndValue(const char* path, const char* subkey, const char* value); 490 static void SetKeyAndValue(const char *path, const char *subkey, const char *value);
490 static void GUIDtochar(const GUID& guid, char* GUID, int length); 491 static void GUIDtochar(const GUID &guid, char *GUID, int length);
491 static void RecursiveDeleteKey(HKEY hKeyParent, const char* child); 492 static void RecursiveDeleteKey(HKEY hKeyParent, const char *child);
492 static const int GUID_STRING_SIZE = 39; 493 static const int GUID_STRING_SIZE = 39;
493 494
494 // Register the component in the registry 495 // Register the component in the registry
495 // When "silent" is TRUE don't give any messages. 496 // When "silent" is TRUE don't give any messages.
496 497
605 } 606 }
606 607
607 /****************************************************************************/ 608 /****************************************************************************/
608 609
609 // Convert a GUID to a char string 610 // Convert a GUID to a char string
610 static void GUIDtochar(const GUID& guid, char* GUID, int length) 611 static void GUIDtochar(const GUID &guid, char *GUID, int length)
611 { 612 {
612 // Get wide string version 613 // Get wide string version
613 LPOLESTR wGUID = NULL; 614 LPOLESTR wGUID = NULL;
614 StringFromCLSID(guid, &wGUID); 615 StringFromCLSID(guid, &wGUID);
615 616
619 // Free memory 620 // Free memory
620 CoTaskMemFree(wGUID); 621 CoTaskMemFree(wGUID);
621 } 622 }
622 623
623 // Delete a key and all of its descendents 624 // Delete a key and all of its descendents
624 static void RecursiveDeleteKey(HKEY hKeyParent, const char* child) 625 static void RecursiveDeleteKey(HKEY hKeyParent, const char *child)
625 { 626 {
626 // Open the child 627 // Open the child
627 HKEY hKeyChild; 628 HKEY hKeyChild;
628 LONG result = RegOpenKeyEx(hKeyParent, child, 0, KEY_ALL_ACCESS, &hKeyChild); 629 LONG result = RegOpenKeyEx(hKeyParent, child, 0, KEY_ALL_ACCESS, &hKeyChild);
629 if (result != ERROR_SUCCESS) 630 if (result != ERROR_SUCCESS)
648 // Delete this child 649 // Delete this child
649 RegDeleteKey(hKeyParent, child); 650 RegDeleteKey(hKeyParent, child);
650 } 651 }
651 652
652 // Create a key and set its value 653 // Create a key and set its value
653 static void SetKeyAndValue(const char* key, const char* subkey, const char* value) 654 static void SetKeyAndValue(const char *key, const char subkey, const char *value)
654 { 655 {
655 HKEY hKey; 656 HKEY hKey;
656 char buffer[1024]; 657 char buffer[1024];
657 658
658 strcpy(buffer, key); 659 strcpy(buffer, key);
682 } 683 }
683 684
684 /***************************************************************************** 685 /*****************************************************************************
685 5. OLE Initialisation and shutdown processing 686 5. OLE Initialisation and shutdown processing
686 *****************************************************************************/ 687 *****************************************************************************/
687 extern "C" void InitOLE(int* pbDoRestart) 688 extern "C" void InitOLE(int *pbDoRestart)
688 { 689 {
689 HRESULT hr; 690 HRESULT hr;
690 691
691 *pbDoRestart = FALSE; 692 *pbDoRestart = FALSE;
692 693