the CComCoClass
来源:互联网 发布:sql注入处理 编辑:程序博客网 时间:2024/06/05 09:42
CComCoClass
CComCoClass provides methods for retrieving an object's CLSID, setting error information, and creating instances of the class. Any class registered in the object map should be derived fromCComCoClass.
提供获取一个对象的CLSID的方法,设置错误信息,并创建类的实例。任何在Object map中注册的类,都必须从CComCoClass继承而来。
它同时也为你的对象定义了默认的类工厂和聚合模型。它使用了一下的两个宏:
DECLARE_CLASSFACTORY 声明一个类工厂为CComClassFactory
DECLARE_AGGREgATABLE 声明你的对象可以被聚合
template <class T, const CLSID* pclsid = &CLSID_NULL>
class CComCoClass
{
public:
DECLARE_CLASSFACTORY()
DECLARE_AGGREGATABLE(T)
typedef T _CoClass;
static const CLSID& WINAPI GetObjectCLSID() {return *pclsid;}
static LPCTSTR WINAPI GetObjectDescription() {return NULL;}
static HRESULT WINAPI Error(LPCOLESTR lpszDesc,
const IID& iid = GUID_NULL, HRESULT hRes = 0)
{
return AtlReportError(GetObjectCLSID(), lpszDesc, iid, hRes);
}
static HRESULT WINAPI Error(LPCOLESTR lpszDesc, DWORD dwHelpID,
LPCOLESTR lpszHelpFile, const IID& iid = GUID_NULL, HRESULT hRes = 0)
{
return AtlReportError(GetObjectCLSID(), lpszDesc, dwHelpID, lpszHelpFile,
iid, hRes);
}
static HRESULT WINAPI Error(UINT nID, const IID& iid = GUID_NULL,
HRESULT hRes = 0, HINSTANCE hInst = _AtlBaseModule.GetResourceInstance())
{
return AtlReportError(GetObjectCLSID(), nID, iid, hRes, hInst);
}
static HRESULT WINAPI Error(UINT nID, DWORD dwHelpID,
LPCOLESTR lpszHelpFile, const IID& iid = GUID_NULL,
HRESULT hRes = 0, HINSTANCE hInst = _AtlBaseModule.GetResourceInstance())
{
return AtlReportError(GetObjectCLSID(), nID, dwHelpID, lpszHelpFile,
iid, hRes, hInst);
}
static HRESULT WINAPI Error(LPCSTR lpszDesc,
const IID& iid = GUID_NULL, HRESULT hRes = 0)
{
return AtlReportError(GetObjectCLSID(), lpszDesc, iid, hRes);
}
static HRESULT WINAPI Error(LPCSTR lpszDesc, DWORD dwHelpID,
LPCSTR lpszHelpFile, const IID& iid = GUID_NULL, HRESULT hRes = 0)
{
return AtlReportError(GetObjectCLSID(), lpszDesc, dwHelpID,
lpszHelpFile, iid, hRes);
}
template <class Q>
static HRESULT CreateInstance(IUnknown* punkOuter, Q** pp)
{
return T::_CreatorClass::CreateInstance(punkOuter, __uuidof(Q), (void**) pp);
}
template <class Q>
static HRESULT CreateInstance(Q** pp)
{
return T::_CreatorClass::CreateInstance(NULL, __uuidof(Q), (void**) pp);
}
};
- the CComCoClass
- CComCoClass
- ATL 的CComCoClass .
- The hell--The hope
- the Denser the Better ?
- the CComSingleThreadModel & the CComMultiThreadModel
- The more, The Better
- the+比较级,the+比较级
- The more, The Better
- The more, The Better
- the good,the bad ,the ugly
- The First!
- The Beginning
- The matrix
- The Singer
- The Makefile
- The thief
- The scrolls
- C#基础教程-委托进阶,将方法绑定到委托
- Printf()输出格式控制
- PHP Socket编程起步
- CDC、HDC、pDC
- jfreechart
- the CComCoClass
- 菜鸟学QT之一-------------HELLO,WORLD
- 即使是当面交谈,都有可能误解
- 让你的C程序更有效率的10种方法
- windows下用iis安装Magento
- 自定义datatable 的列
- 一步一步实现C++操作SQLite数据库
- 利用sqoop将hive数据导入导出数据到mysql
- HTML&CSS 定位