P6R::P6ERR classname::queryInterface(const P6R::IID &iid, P6R::P6VOID** ppv) { \
if(!ppv) \
return P6R::eAccessFault; \
*ppv = NULL; \
if(iid == IID_p6ICom) *ppv = static_cast<interface1*>(this); \
else if(iid == IID_##interface1) *ppv = static_cast<interface1*>(this); \
else if(iid == IID_##interface2) *ppv = static_cast<interface2*>(this); \
else if(iid == IID_##interface3) *ppv = static_cast<interface3*>(this); \
else return P6R::eNoInterface; \
reinterpret_cast<p6ICom*>(*ppv)->addref(); \
return P6R::eOk; \
} \
P6_IMPLEMENT_THREADSAFE_ADDREF(classname) \
P6_IMPLEMENT_THREADSAFE_RELEASE(classname) \
P6_IMPLEMENT_CREATEINSTANCE_NO_AGG(classname)