Détermination de l’interface prise en charge par un objet
La méthode QueryInterface permet à une application de demander à un objet de déterminer les interfaces qu’il prend en charge. L’exemple d’application définit le pointeur PPV sur l’interface actuelle.
STDMETHODIMP CAVIFileCF::QueryInterface(
const IID FAR& iid,
void FAR* FAR* ppv)
{
if (iid == IID_IUnknown)
*ppv = this; // set the interface pointer
// to this instance
else if (iid == IID_IClassFactory)
*ppv = this; // second chance to set the
// interface pointer to this
// instance
else
return ResultFromScode(E_NOINTERFACE);
AddRef(); //Increment the reference count
return NULL;
}