Pass CComPrt to and from function
Hi there,
I'm trying to use CComPtr class. What's the right way to pass to and
return from function CComPrt object? Following is the snippet of code
that I have so far. It compiles and seems to do what I need, but I'm
not sure if it's Ok to pass entire class back and forth.
Thanks for your help,
Bob
//************ Header file *********
class CLRHost
{
public:
CLRHost();
virtual ~CLRHost();
CComPtr<ICorRuntimeHost> GetCComPtr(void);
SetComPtr(CComPtr<ICorRuntimeHost>);
private:
CComPtr<ICorRuntimeHost> rntHost;
CComPtr<_AppDomain> spDefAppDomain;
CComPtr<_ObjectHandle> spObjectHandle;
CComPtr<IDispatch> pDisp;
};
//************* Class implementation (.Cpp file) ***
CComPtr<ICorRuntimeHost> CLRHost::GetCComPtr(void)
{
return rntHost;
}
void CLRHost::SetCComPtr(CComPtr<ICorRuntimeHost> _rntHost)
{
rntHost = _rntHost;
}
....
....
....
//************** Call to the clrHost object to set/get CComPtr ****
CComPtr<ICorRuntimeHost> host;
clrHost.SetCComPtr(spRuntimeHost);
host = clrHost.GetCComPtr();