templatelt คลาสT (&L)gt
คลาส CComPtr(&G)
พารามิเตอร์
T
อินเทอร์เฟซ COM ระบุชนิดของตัวชี้การจัดเก็บ?
ATL ใช้CComPtrและCComQIPtrเพื่อจัดการตัวชี้ของอินเทอร์เฟซ COM ชั้นทั้งสองทำการอ้างอิงอัตโนมัติผ่านไปยังAddRefและปล่อยการตรวจนับ ตัวดำเนินการ overloaded จัดการดำเนินงานตัวชี้ CComQIPtrนอกจากนี้สนับสนุนโดยอัตโนมัติสอบของอินเทอร์เฟซแม้ว่าQueryInterface?
รหัสต่อไปนี้มาจากCFirePropNotifyEvent::FireOnRequestEdit
คง hresult ใน FireOnRequestEdit(IUnknown* pUnk, DISPID dispID)
{
nbsp CComQIPtr < IConnectionPointContainer และ IID_IConnectionPointContainer > pCPC(pUnk)
ถ้า (! pCPC)
กลับ S_OK
PCP CComPtr <IConnectionPoint>
pCPC - > FindConnectionPoint (IID_IPropertyNotifySink, & pCP);
ถ้า (! pCP)
กลับ S_OK
...
}
ตัวอย่างนี้แสดงต่อไปนี้:
pCPC เรียกQueryInterfaceบน pUnk เพื่อขอรับตัวชี้IConnectionPointContainer ชี้ตัวดึงข้อมูลจะถูกเก็บไว้ในpCPC?pCP กุมชี้การIConnectionPoint?pCPC เรียกตัวชี้การIConnectionPointทางpCP?#รวม lt;atlbase.h>
ดูเพิ่มเติมnbspCComPtr::CComPtr, CComQIPtr::CComQIPtr(&N)