Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

_com_ptr_t::QueryInterface

91 views
Skip to first unread message

Konstantine Smaguine

unread,
Aug 3, 1999, 3:00:00 AM8/3/99
to
I'm trying to use COM smart pointer and its QueryInterface method to avoid
explicit typecasting to void**. The QueryInterface method is described as
follows in the Help:

template<typename _InterfaceType> HRESULT QueryInterface ( const IID& iid,
_InterfaceType*& p ) throw ( );

template<typename _InterfaceType> HRESULT QueryInterface ( const IID& iid,
_InterfaceType** p) throw( );

In reality, I'm unable to use the second form because if I have

IDebugApplication **ppda;

then

_COM_SMARTPTR_TYPEDEF(IDebugApplication, __uuidof(IDebugApplication));
IDebugApplicationPtr debug_application_ptr;

debug_application_ptr.QueryInterface(IID_IDebugApplication, ppda);

produces an error (error C2667: 'QueryInterface' : none of 2 overload have a
best conversion), presumably because IDebugApplication ** can be converted
to IUnknown ** implicitly.

Does anyone has other experience with this? Thanks!

--
Yours,
Konstantine Smaguine
GSB Computing Services

nos...@gsb.uchicago.edu
replace nospam with firstname.lastname to get my e-mail address

Alexander Nickolov

unread,
Aug 3, 1999, 3:00:00 AM8/3/99
to
You have one mistake - instead of
>IDebugApplication **ppda;
use
IDebugApplication *pda;

then:
debug_application_ptr.QueryInterface(IID_IDebugApplication, &pda);
or
debug_application_ptr.QueryInterface(IID_IDebugApplication, pda);

BTW, you usually ask for another interface here...

--
===============================
Alexander Nickolov, MCP
Panasonic Technologies Inc.
Speech Technology Laboratory
email: agnic...@geocities.com
===============================

Konstantine Smaguine wrote in message ...

Konstantine Smaguine

unread,
Aug 3, 1999, 3:00:00 AM8/3/99
to
I'm getting IDebugApplication ** as an [out] parameter. If I use *ppda, the
first form of QueryInterface template is chosen, and I have no problems.

--
Yours,
Konstantine Smaguine
GSB Computing Services

nos...@gsb.uchicago.edu
replace nospam with firstname.lastname to get my e-mail address

Alexander Nickolov wrote in message ...

0 new messages