In this C++/COM shell extension tutorial, the programmer demonstrates (for purposes of edification) that you can forego calling QueryInterface()
and simply pass around a general object instead. At least that works when implementing DllGetClassObject()
. He says the purpose of QueryInterface()
is just to have each object speak for itself as to whether it supports a given interface.
Microsoft, meanwhile, seems to say that QueryInterface()
is necessary to get a pointer to a specific interface on an object.
So to what extent is QueryInterface()
necessary? Is there any time when calling QueryInterface()
is absolutely essential, and without it the code wouldn't work? Or is getting the object itself technically sufficient, as the video tutorial suggests?