March 7th, 2003, 10:32 AM
Use of SmartPointer CComPtr in ATL programming
I want to create an instance of an automation server program (s.a.excel) with SmartPointer from ATL program.
I have imported the tlb libraries with the import statement
#import "caxolesrv.tlb" raw_native_types, no_namespace, named_guids
What do I have to do to get a new instance of automation server and start it automaticly. With MFC OLE I can use CreateObject(..) but in ATL I cannot find a equivalent function.
To get it without smart pointer was also not succesful
HRESULT hr = -10;
IDispatch *pDisp = NULL;
hr = CoCreateInstance(clsid, NULL, CLSCTX_ALL, IID_IDispatch, (void**)&pDisp);
Thanks for your help,
March 7th, 2003, 04:28 PM
This works for me.
hr = pMyInterface.CoCreateInstance(CLSID_MyInterface);
March 7th, 2003, 04:52 PM
the solution is the following line:
hr = m_iCaxOleSrv.CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER);
this does not work:
hr = m_iCaxOleSrv.CoCreateInstance(clsid, NULL, CLSCTX_ALL);
My be this is a bug.
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!