Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. how to return from IDispatch invoke?

how to return from IDispatch invoke?

Scheduled Pinned Locked Moved COM
helptutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • 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.
  • S Offline
    S Offline
    safee ullah
    wrote on last edited by
    #1

    hi there.. i am working on a spread sheet control..and need to know if there is any problem with the way i am returning from the Invoke call.. When run this method throws an access violation...any ideas.?? here is the code.. long CControl :: GetObjCellCol(long ObjID) { DISPPARAMS DispParam1; EXCEPINFO excep; UINT nArgErr; DISPID dispidNamed; VARIANT * pResult = NULL; DispParam1.cArgs = 1; //number of arguments DispParam1.cNamedArgs = 0; // named arguments. DispParam1.rgdispidNamedArgs = &dispidNamed; // Dispatch IDs of named arguments. DispParam1.rgvarg = new VARIANTARG(); DispParam1.rgvarg->vt = VT_I4; DispParam1.rgvarg->lVal = ObjID; IImpl::Invoke(DISPID_F1_CellCol, IID_NULL , 0 , NULL, &DispParam1,pResult , &excep, &nArgErr); return pResult->lVal; }

    M 1 Reply Last reply
    0
    • S safee ullah

      hi there.. i am working on a spread sheet control..and need to know if there is any problem with the way i am returning from the Invoke call.. When run this method throws an access violation...any ideas.?? here is the code.. long CControl :: GetObjCellCol(long ObjID) { DISPPARAMS DispParam1; EXCEPINFO excep; UINT nArgErr; DISPID dispidNamed; VARIANT * pResult = NULL; DispParam1.cArgs = 1; //number of arguments DispParam1.cNamedArgs = 0; // named arguments. DispParam1.rgdispidNamedArgs = &dispidNamed; // Dispatch IDs of named arguments. DispParam1.rgvarg = new VARIANTARG(); DispParam1.rgvarg->vt = VT_I4; DispParam1.rgvarg->lVal = ObjID; IImpl::Invoke(DISPID_F1_CellCol, IID_NULL , 0 , NULL, &DispParam1,pResult , &excep, &nArgErr); return pResult->lVal; }

      M Offline
      M Offline
      Mike Dimmick
      wrote on last edited by
      #2

      pResult is NULL. You should be passing the address of a valid VARIANT structure, i.e.:

      VARIANT vtResult = { 0 };

      // ...

      IImpl::Invoke(
      DISPID_F1_CellCol,
      IID_NULL,
      0,
      NULL,
      &DispParam1,
      &vtResult,
      &excep,
      &nArgErr
      );

      return vtResult.lVal;

      When the called component comes to fill in the result value, it tries to write through a NULL pointer and causes the access violation. Hope this helps.

      S 1 Reply Last reply
      0
      • M Mike Dimmick

        pResult is NULL. You should be passing the address of a valid VARIANT structure, i.e.:

        VARIANT vtResult = { 0 };

        // ...

        IImpl::Invoke(
        DISPID_F1_CellCol,
        IID_NULL,
        0,
        NULL,
        &DispParam1,
        &vtResult,
        &excep,
        &nArgErr
        );

        return vtResult.lVal;

        When the called component comes to fill in the result value, it tries to write through a NULL pointer and causes the access violation. Hope this helps.

        S Offline
        S Offline
        safee ullah
        wrote on last edited by
        #3

        oooooooooops thanks :))

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups