📄 comm.h
字号:
#ifndef __COMM_H_
#define __COMM_H_
template <class InterFaceName>
class _CopyVariantFromLong
{
public :
static void init(VARIANT* p) { VariantInit (p); }
static void destroy(VARIANT* p) { VariantClear (p); }
static HRESULT copy(VARIANT* pTo, const UINT* pFrom)
{
if(!pTo)return S_FALSE;
VariantClear (pTo);
CComPtr<InterFaceName> p = (InterFaceName*)(*pFrom);
HRESULT hr = p.CopyTo((InterFaceName**)&pTo->pdispVal);
if(FAILED(hr)) return S_FALSE;
pTo->vt = VT_DISPATCH;
return S_OK;
}
};
template <class InterFaceName>
class _CopyInterFaceFromLong
{
public :
static void init(InterFaceName** p)
{
return;
}
static void destroy(InterFaceName** p)
{
//if(p && *p)
//{
// (*p)->Release();
// (*p) = NULL;
//}
return;
}
static HRESULT copy(InterFaceName** pTo, const UINT* pFrom)
{
CComPtr<InterFaceName> p = (InterFaceName*)(*pFrom);
HRESULT hr = p.CopyTo(pTo);
if(FAILED(hr)) return S_FALSE;
return S_OK;
}
};
template <class ParentInterFaceName,class ChildInterFaceName>
class _EnumColl
{
public:
typedef std::vector<UINT> ContainerType;
typedef VARIANT EnumeratorExposedType;
typedef IEnumVARIANT EnumeratorInterface;
typedef ChildInterFaceName* CollectionExposedType;
typedef ParentInterFaceName CollectionInterface;
typedef _CopyVariantFromLong<ChildInterFaceName> EnumeratorCopyType;
typedef _CopyInterFaceFromLong<ChildInterFaceName> CollectionCopyType;
typedef CComEnumOnSTL< EnumeratorInterface,
&__uuidof(EnumeratorInterface),
EnumeratorExposedType,EnumeratorCopyType,
ContainerType > EnumeratorType;
typedef ICollectionOnSTLImpl< CollectionInterface,
ContainerType, CollectionExposedType,
CollectionCopyType, EnumeratorType > CollectionType;
};
#endif //__COMM_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -