Create a COM object inside another COM object

I have the following interface. An interface returns an interface ISystemCmdsas part of a method GetSystemCommandInterface. We use ATL to create COM.

interface IDevice : IDispatch{  
 [id(1), helpstring("method Connect")] HRESULT Connect([in] VARIANT varPortNo);    
 [id(2), helpstring("method GetSystemCommandInterface")] HRESULT GetSystemCommandInterface([out,retval] ISystemCmds** pISystemCmd);    
};

What code should be added (and where) to create a COM object for ISystemCmds, if

and. Am I creating a COM object for ISystemCmds as part of creating a COM object IDevice?
b. Am I creating a COM object in method GetSystemCommandInterface()?

+3
source share
2 answers

ATL ISystemCmds. CoCreateInstance CComObject < > (. CreateInstance), , ISystemCmds . , CComObject < > :: CreateInstance() AddRef() , QueryInterface() CoCreateInstance(). AddRef !

+2

COM- - , , , , , , ISystemCmds IDevice. QueryInterface GetSystemCommandInterface.

+1

All Articles