Passing COM smart pointer as Reference
Posted on 2006-10-24
I am having A smart pointer in main application and i want to pass the reference to a function in another class
which is instantiated in the main application. I am a beginner in COM and i dont know how to do this, i am posting the
sample code i experimented with. Could any one tell me how to do this? and where i am going wrong.
spUttil.CreateInstance(__uuidof(Util)); //Util is a CoClass inside COM
only one instance of Util should be instanciated for the whole application
but Many Instances of Utilities will be created based on Util.
spMyUtil.CreateInstance(__uuidof(Util)); //Util is a GUID of a CoClass inside the COM
spMyUtilities.CreateInstance(__uuidof(Utilities)); //Utilities is a GUID of another CoClass
inside the COM
void SetInterface(IUtilPtr MyUt)
I dont get any compile error but the actual ref of the Interface pointer is not
copied to the local smart pointer of the function
spMyUtil = MyUt;
spMyUtilities = (IUtilitiesPtr) spMyUtil -> CreateUtility();
//Function CreateUtility Creates a Utilities object
//since the return type is IUnknownPtr it is casted to IUtitlitiesPtr before it is assigned to
Thanx in advance.
Shiju S N