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. IDispatch:Invoke - Runtime Access Violation error when accessing DISPARARAM &dp

IDispatch:Invoke - Runtime Access Violation error when accessing DISPARARAM &dp

Scheduled Pinned Locked Moved COM
helpquestion
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.
  • T Offline
    T Offline
    tm
    wrote on last edited by
    #1

    before invoking the IDispacth::invoke I do the following: BOOL CLASSNAME ::InvokeGetValue( IDispatch *InDispatch, DISPID& InDispId, LCID& InLcid, long InUserComId, CString& OutValue, BOOL bAdhocCom, int NumToReserve, CString& Name1, CString& Name2) { CString strReturn; VARIANTARG va; EXCEPINFO exInfo; UINT uErr; DISPPARAMS dp; HRESULT hr; BSTR argConversion; BSTR sName1= Name1.AllocSysString(); BSTR sName2= Name2.AllocSysString(); Num=32; int nArgs = 3; dp.cArgs = nArgs; dp.cNamedArgs = 0; //////???AT RUN TIME IT CRASHES ON THE NEXT INSTRUCTION ///// COMPLAINIG ABOUT UNHANDLED EXCEPTION- ACCESS VIOLATION dp.rgvarg[0].vt = VT_I2; dp.rgvarg[0].iVal = NumToReserve; ANY HELP IS HIGHLY APPRECIATED. Paradise is where I am. Voltaire

    L 1 Reply Last reply
    0
    • T tm

      before invoking the IDispacth::invoke I do the following: BOOL CLASSNAME ::InvokeGetValue( IDispatch *InDispatch, DISPID& InDispId, LCID& InLcid, long InUserComId, CString& OutValue, BOOL bAdhocCom, int NumToReserve, CString& Name1, CString& Name2) { CString strReturn; VARIANTARG va; EXCEPINFO exInfo; UINT uErr; DISPPARAMS dp; HRESULT hr; BSTR argConversion; BSTR sName1= Name1.AllocSysString(); BSTR sName2= Name2.AllocSysString(); Num=32; int nArgs = 3; dp.cArgs = nArgs; dp.cNamedArgs = 0; //////???AT RUN TIME IT CRASHES ON THE NEXT INSTRUCTION ///// COMPLAINIG ABOUT UNHANDLED EXCEPTION- ACCESS VIOLATION dp.rgvarg[0].vt = VT_I2; dp.rgvarg[0].iVal = NumToReserve; ANY HELP IS HIGHLY APPRECIATED. Paradise is where I am. Voltaire

      L Offline
      L Offline
      Lily18
      wrote on last edited by
      #2

      did you initialize : VariantInit(va);//your variant and dp.rgvarg = va;//your dispparam with you variant? access violation is often null pointer...!

      T 1 Reply Last reply
      0
      • L Lily18

        did you initialize : VariantInit(va);//your variant and dp.rgvarg = va;//your dispparam with you variant? access violation is often null pointer...!

        T Offline
        T Offline
        tm
        wrote on last edited by
        #3

        The problem was solved by a codeguru member: CComVariant dpv[3]; dp.rgvarg = dpv; I was not allocating space for the dp array structure. Thank you very much for you reply. I believe your dp.rgvarg = va;//your dispparam with you variant? statement was in the same general direction too. Thanks again. Paradise is where I am. Voltaire

        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