⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kvpair.h

📁 使用CT-C开发的一个CTI软电话系统,ActiveX形式的,仅供参考
💻 H
字号:
// KVPair.h : Declaration of the CKVPair

#ifndef __KVPAIR_H_
#define __KVPAIR_H_

#include "resource.h"       // main symbols
#include "jstring"

using namespace std;

#define	DECLARE_CASTER(Class, Interface)	extern Class *I2C(Interface *pInterface);
#define	DECLARE_CREATOR(Class, Interface)	extern HRESULT CreateClass(Class **ppClass, Interface **ppInterface);

extern BSTR C2B(const char *c);

/////////////////////////////////////////////////////////////////////////////
// CKVPair
class ATL_NO_VTABLE CKVPair : 
	public CComObjectRootEx<CComMultiThreadModel>,
	public CComCoClass<CKVPair, &CLSID_KVPair>,
	public IKVPair
{
public:
	CKVPair()
	{
		m_type = KVT_Incorrect;
		m_length = 0;
		m_intValue = 0;
		m_listValue = NULL;
		m_binaryValue = NULL;
		m_pUnkMarshaler = NULL;
	}
	BOOL Initialize(TKVPair *pPair);

DECLARE_REGISTRY_RESOURCEID(IDR_KVPAIR)
DECLARE_NOT_AGGREGATABLE(CKVPair)
DECLARE_GET_CONTROLLING_UNKNOWN()

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CKVPair)
	COM_INTERFACE_ENTRY(IKVPair)
	COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)
END_COM_MAP()

	HRESULT FinalConstruct()
	{
		return CoCreateFreeThreadedMarshaler(
			GetControllingUnknown(), &m_pUnkMarshaler.p);
	}

	void FinalRelease()
	{
		if(m_listValue) TKVListFree(m_listValue);
		if(m_binaryValue) delete[](m_binaryValue);
		m_pUnkMarshaler.Release();
	}

	CComPtr<IUnknown> m_pUnkMarshaler;

	KVTYPES m_type;
	jstring m_key;
	int m_length;
	jstring m_stringValue;
	int m_intValue;
	TKVList *m_listValue;
	byte *m_binaryValue;

// IKVPair
public:
	STDMETHOD(get_BinaryLength)(/*[out, retval]*/ int *pVal);
	STDMETHOD(get_BinaryValue)(/*[out, retval]*/ byte * *pVal);
	STDMETHOD(get_ListValue)(/*[out, retval]*/ LPKVLIST *pVal);
	STDMETHOD(get_IntValue)(/*[out, retval]*/ int *pVal);
	STDMETHOD(get_StringValue)(/*[out, retval]*/ BSTR *pVal);
	STDMETHOD(get_Key)(/*[out, retval]*/ BSTR *pVal);
	STDMETHOD(get_Type)(/*[out, retval]*/ KVTYPES *pVal);
};

#endif //__KVPAIR_H_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -