Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Calling a CAPL function from QT using com and Canalyzr

Calling a CAPL function from QT using com and Canalyzr

Scheduled Pinned Locked Moved General and Desktop
c++canalyzercom
5 Posts 2 Posters 2.9k Views
  • 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 Offline
    H Offline
    hichem
    wrote on last edited by
    #1

    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
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      0
      • H Offline
        H Offline
        hichem
        wrote on last edited by
        #3

        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
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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
          0
          • H Offline
            H Offline
            hichem
            wrote on last edited by
            #5

            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
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved