@H_403_0@ATL包含和聚合
@H_403_0@实现聚合的步骤:
1.创建一个内部主件
2.创建一个外部主件
3.添加代码
IUnknown* m_pSimpleUnknow;
DECLARE_GET_CONTROLLING_UNKNOWN()
@H_403_0@
HRESULT FinalConstruct()
{
HRESULT hr = CoCreateInstance(CLSID_MyMath,GetControllingUnknown(),
CLSCTX_INPROC_SERVER,IID_IUnknown,(void**)&m_pSimpleUnknow);
return hr;
}
@H_403_0@void FinalRelease()
{
if(m_pSimpleUnknow)
{
m_pSimpleUnknow->Release();
}
}
实现包容的步骤:
1.创建一个内部主件
2.创建一个外部主件
3.添加代码
继承IMyMath接口
COM_INTERFACE_ENTRY(IMyMath)
IMyMath *m_pMath;
HRESULT FinalConstruct()
{
HRESULT hr = CoCreateInstance(CLSID_MyMath,CLSCTX_INPROC_SERVER,IID_IMyMath,(void**)&m_pMath);
return hr;
}
@H_403_0@void FinalRelease()
{
if(m_pMath)
{
m_pMath->Release();
@H_403_0@} } 原文链接:https://www.f2er.com/javaschema/286533.html