Calling a CAPL function from QT using com and Canalyzr
-
want to call a function from QT application in facet this function exist a CAPL script runing in Canalyzer I am using COM to get access to the function here my exemple but it doesnt work where is the problem any help plz
ICAPL *pcapl;
ICAPLFunction fn ;
IApplication pIApp;HRESULT result,result1,result2, hresult,result3,result4,hr;
IDispatch*CaplDisp,*CaplFn;
WCHAR * szMember = L"Multiply";
DISPID dispid;
DISPPARAMS dispparams = {NULL, NULL, 0, 0};
EXCEPINFO excepinfo;
UINT nArgErr;
CLSID clsid;result = CLSIDFromProgID(L"CANalyzer.Application", &clsid);
const IID IID_CAPL =__uuidof(ICAPL);const IID IID_CAPLFUNCTION =__uuidof(ICAPLFunction); const IID IID_IApplication =__uuidof(IApplication);
result = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER, IID_IApplication, (void**) &pIApp);
result1=pIApp->get_CAPL(&CaplDisp);
qDebug() << "Result_get_CAPL "<<result1 ;
result2=CaplDisp->QueryInterface(IID_CAPL,(void**)&pcapl);
qDebug() << "result2 "<<result2 ;VARIANT varResult;
hr = CaplDisp->GetIDsOfNames(IID_CAPLFUNCTION, &szMember, 1, CLSCTX_LOCAL_SERVER, &dispid);
qDebug() << "hr"<<hr ;
if (SUCCEEDED(hr)) {
hr = CaplDisp->Invoke(1,IID_CAPL, CLSCTX_LOCAL_SERVER,DISPATCH_METHOD,&dispparams, &varResult, NULL, NULL);
} -
Hi,
You should also add what the problem is. What are you excpecting ? What are you currently getting ?
-
what i want is to call the function L"Multiply" from the a CAPL script located in CANalyzer but I can't this *
- [hr = CaplDisp->GetIDsOfNames(IID_CAPLFUNCTION, &szMember, 1, CLSCTX_LOCAL_SERVER, &dispid);]
returned an error
I try like this :
-
ICAPL pcapl;
_IApplicationEventsx;
ICAPLFunction fn ;
IApplication pIApp;
HRESULT result,result1,result2, hresult,result3,result4,hr;
IDispatch*CaplDisp,*CaplFn;
WCHAR * szMember = L"Multiply";
DISPID dispid;
DISPPARAMS dispparams = {NULL, NULL, 0, 0};
EXCEPINFO excepinfo;
UINT nArgErr;
CLSID clsid;result = CLSIDFromProgID(L"CANalyzer.Application", &clsid);
const IID IID_CAPL =__uuidof(ICAPL);const IID IID_CAPLFUNCTION =__uuidof(ICAPLFunction);
const IID IID_IApplication =__uuidof(IApplication);result = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER, IID_IApplication, (void**) &pIApp);
result1=pIApp->get_CAPL(&CaplDisp);
qDebug() << "Result_get_CAPL "<<result1 ;
result2=CaplDisp->QueryInterface(IID_CAPL,(void**)&pcapl);
result3=pcapl->GetFunction(L"Multiply",&CaplFn);
but result3 gives an error I need help please
- [hr = CaplDisp->GetIDsOfNames(IID_CAPLFUNCTION, &szMember, 1, CLSCTX_LOCAL_SERVER, &dispid);]
-
What is the error you are getting ?
You're also not checking the different value that result get before calling get_CAPL
-
now get_function it is ok
now i want to call a function with two argument but ICAPLfunction::Call must have ten argument what should i do
here my exemple:
VARIANT p[10];
p[0].lVal=1;p[1].lVal=4;p[2].lVal=0;p[3].lVal=0;p[4].lVal=0;p[5].lVal=0;p[6].lVal=0;p[7].lVal=0;p[8].lVal=0;p[9].lVal=0;
VARIANT r;result4=fn->Call( p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], &r);