I am wondering how I can define a COM pointer as a private member. Here is what I want to do:
in h file:
MCLControlPtr _mcSwitch; //MCLControPtr is "_COM_SMARTPTR_TYPEDEF(_MCLControlClass, __uuidof(_MCLControlClass));"
in cpp constructor file
ThorDetectorSwitch::ThorDetectorSwitch()
{
_mcSwitch = new MCLControlPtr _mcSwitch(__uuidof(MCLControlClass));
_deviceDetected = FALSE;
}
but of course it does not allow me to build because the syntax is not right.
I am wondering how I can do what I want to do with the right syntax? Basically initilize a COM smart pointer in constructor? I also do NOT want to use initilization list as well. Thanks.
UPDATE: Anyone has any idea? This is really bothering me for days.
You can do something like this:
In your head file
COMInterface *_comInterface;
In your cpp file
COMInterfacePtr comSmartPtr;
hr = ::CoCreateInstance(see reference for stuff inside here);
_comInterface = comSmartPtr;