Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Calling a CAPL function from QT using com and Canalyzr

    General and Desktop
    c++ canalyzer com
    2
    5
    2417
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      hichem last edited by

      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);
      }

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        You should also add what the problem is. What are you excpecting ? What are you currently getting ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 0
        • H
          hichem last edited by

          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;
            _IApplicationEvents
            x;
            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

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            What is the error you are getting ?

            You're also not checking the different value that result get before calling get_CAPL

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 0
            • H
              hichem last edited by

              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);
              
              1 Reply Last reply Reply Quote 0
              • First post
                Last post