We can see the following code in the header file atlbase. h:
//////////////////////////////////////// /////////////////////////////////////
// Connection point helpers
Atlinline atlapi atladvise (iunknown * punkcp, iunknown * punk, const IID & IID, lpdword PDW)
{
Ccomptr <iconnectionpointcontainer> pcpc; // container of the connection point, or the Event Server
Ccomptr <iconnectionpoint> PCP; // connection point object
Hresult hres = punkcp-> QueryInterface (iid_iconnectionpointcontainer, (void **) & pcpc );
If (succeeded (hres ))
Hres = pcpc-> findconnectionpoint (IID, & PCP); // locate the connection point
If (succeeded (hres ))
Hres = PCP-> advise (punk, PDW); // Mount
Return hres;
}
Atlinline atlapi atlunadvise (iunknown * punkcp, const IID & IID, dword dw)
{
Ccomptr <iconnectionpointcontainer> pcpc;
Ccomptr <iconnectionpoint> PCP;
Hresult hres = punkcp-> QueryInterface (iid_iconnectionpointcontainer, (void **) & pcpc );
If (succeeded (hres ))
Hres = pcpc-> findconnectionpoint (IID, & PCP );
If (succeeded (hres ))
Hres = PCP-> unadvise (DW );
Return hres;
}
It is very refined, and many functional pointers are used! Hoho!
Write down interesting things and share them with you!