Basic COM  «Prev 

Client's View of IUnknown

Module 2 Lesson 13

Line 1:The declaration of an HRESULT. This is used to hold the return value of COM calls.
Lines 2 and 3:Here MyComObject is initialized and we get an interface pointer to interface IMyComObject. We will cover the details of how this is done in the next module.
Line 4:A call is made to IMyComInterface::Fx2.
Line 5:A check is made on the return value from Fx2. FAILED is a standard COM error checking macro.
Lines 7:This declares a variable as a pointer to COM interface IYourComInterface.
Lines 9 and 10:IMyComInterface::QueryInterface is called to get a pointer to IYourComInterface.
Line 13:If the QueryInterface call is successful, this calls IYourComInterface::Zx1.
Line 14:The FAILED macro is used to check the status of the previous COM call.
Line 16:This calls IMyComInterface::Release.
Line 17:This calls IYourComInterface::Release. Interface pointers held by a client should be considered invalid after calling Release.