comm.h
来自「使用方法如下: 1、在工程中加入comm.h这个头文件 2、在stdafx.h中」· C头文件 代码 · 共 70 行
H
70 行
#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 + =
减小字号Ctrl + -
显示快捷键?