xref: /vim-8.2.3635/src/VisVim/OleAut.h (revision 071d4279)
1 #ifndef __OLEAUT_H__
2 #define __OLEAUT_H__
3 
4 class COleAutomationControl : public CObject
5 {
6     public:
7 	COleAutomationControl ();
8 	~COleAutomationControl ();
9 	bool CreateObject (char* ProgId);
10 	DISPID GetDispatchId (char* Name);
11 	bool GetProperty (char* Name);
12 	bool GetProperty (DISPID DispatchId);
13 	bool PutProperty (char* Name, LPCTSTR Format, ...);
14 	bool PutProperty (DISPID DispatchId, LPCTSTR Format, ...);
15 	bool Method (char* Name, LPCTSTR Format = NULL, ...);
16 	bool Method (DISPID DispatchId, LPCTSTR Format = NULL, ...);
17 	void DeleteObject ();
18 	void ErrDiag ();
IsCreated()19 	bool IsCreated ()
20 	{
21 		return m_pDispatch ? true : false;
22 	}
23 	bool IsAlive ();
GetResult()24 	HRESULT GetResult ()
25 	{
26 		return m_hResult;
27 	}
GetErrArgNr()28 	UINT GetErrArgNr ()
29 	{
30 		return m_nErrArg;
31 	}
GetExceptionInfo()32 	EXCEPINFO* GetExceptionInfo ()
33 	{
34 		return &m_ExceptionInfo;
35 	}
GetResultVariant()36 	LPVARIANT GetResultVariant ()
37 	{
38 		return &m_VariantResult;
39 	}
40 
41     protected:
42 	bool Invoke (WORD Flags, char* Name, LPCTSTR Format, va_list ArgList);
43 	bool Invoke (WORD Flags, DISPID DispatchId, LPCTSTR Format, va_list ArgList);
44 
45     protected:
46 	IDispatch*	m_pDispatch;
47 	HRESULT		m_hResult;
48 	UINT		m_nErrArg;
49 	EXCEPINFO	m_ExceptionInfo;
50 	VARIANTARG	m_VariantResult;
51 };
52 
53 #ifdef UNICODE
54     #define FROM_OLE_STRING(str)		str
55     #define FROM_OLE_STRING_BUF(str,buf)	str
56     #define TO_OLE_STR(str)			str
57     #define TO_OLE_STR_BUF(str,buf)		str
58     #define MAX_OLE_STR				1
59 #else
60     #define FROM_OLE_STR(str)			ConvertToAnsi(str)
61     #define FROM_OLE_STR_BUF(str,buf)		ConvertToAnsiBuf(str,buf)
62     char* ConvertToAnsi (OLECHAR* sUnicode);
63     char* ConvertToAnsiBuf (OLECHAR* sUnicode, char* Buf);
64     #define TO_OLE_STR(str)			ConvertToUnicode(str)
65     #define TO_OLE_STR_BUF(str,buf)		ConvertToUnicodeBuf(str,buf)
66     OLECHAR* ConvertToUnicode (char* sAscii);
67     OLECHAR* ConvertToUnicodeBuf (char* sAscii, OLECHAR* Buf);
68     // Maximum length of string that can be converted between Ansi & Unicode
69     #define MAX_OLE_STR				500
70 #endif
71 
72 
73 #endif		 // __OLEAUT_H__
74