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. C / C++ / MFC
  4. Access violation trying to use ActiveX dll

Access violation trying to use ActiveX dll

Scheduled Pinned Locked Moved C / C++ / MFC
comhelpquestionc++
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.
  • K Offline
    K Offline
    Killen
    wrote on last edited by
    #1

    Hi! I'm trying to use an ActiveX dll in my C++ program. The dll is written in VB (not by me), so I generated a h-file from the idl. Everything compiles, but when I run the test program I get an error at the line with a :confused: below. The code is really simple, but I don't know what is causing the error. Anyone familiar with what might be wrong here? Thanks... void TestDlg::OnOK() { HRESULT hRes; _cTheObj *pTheObj = NULL; UpdateData(TRUE); // Init COM hRes = CoInitialize(0); if (SUCCEEDED(hRes)) { // Create object hRes = CoCreateInstance(CLSID_cTheObj, NULL, CLSCTX_INPROC_SERVER, IID__cTheObj, (LPVOID *)&pTheObj); if (SUCCEEDED(hRes)) { SHORT ret; VARIANT l1; VariantInit(&l1); l1.vt = VT_BSTR; l1.bstrVal = m_logon1.AllocSysString(); hRes = pTheObj->Logon(l1, &ret); :confused: The definition of the Logon funcition in the h-file for the dll looks like: virtual /* [id] */ HRESULT STDMETHODCALLTYPE Logon( /* [in] */ VARIANT arg1, /* [in] */ VARIANT arg2, /* [in] */ VARIANT arg3, /* [retval][out] */ VARIANT_BOOL __RPC_FAR *__MIDL_0014) = 0; Thanks for any help!

    A 1 Reply Last reply
    0
    • K Killen

      Hi! I'm trying to use an ActiveX dll in my C++ program. The dll is written in VB (not by me), so I generated a h-file from the idl. Everything compiles, but when I run the test program I get an error at the line with a :confused: below. The code is really simple, but I don't know what is causing the error. Anyone familiar with what might be wrong here? Thanks... void TestDlg::OnOK() { HRESULT hRes; _cTheObj *pTheObj = NULL; UpdateData(TRUE); // Init COM hRes = CoInitialize(0); if (SUCCEEDED(hRes)) { // Create object hRes = CoCreateInstance(CLSID_cTheObj, NULL, CLSCTX_INPROC_SERVER, IID__cTheObj, (LPVOID *)&pTheObj); if (SUCCEEDED(hRes)) { SHORT ret; VARIANT l1; VariantInit(&l1); l1.vt = VT_BSTR; l1.bstrVal = m_logon1.AllocSysString(); hRes = pTheObj->Logon(l1, &ret); :confused: The definition of the Logon funcition in the h-file for the dll looks like: virtual /* [id] */ HRESULT STDMETHODCALLTYPE Logon( /* [in] */ VARIANT arg1, /* [in] */ VARIANT arg2, /* [in] */ VARIANT arg3, /* [retval][out] */ VARIANT_BOOL __RPC_FAR *__MIDL_0014) = 0; Thanks for any help!

      A Offline
      A Offline
      antlers
      wrote on last edited by
      #2

      Looks like you are only passing one argument where it is expecting 3, and looks like it might not be initialized, at that.

      K 1 Reply Last reply
      0
      • A antlers

        Looks like you are only passing one argument where it is expecting 3, and looks like it might not be initialized, at that.

        K Offline
        K Offline
        Killen
        wrote on last edited by
        #3

        Oh, I'm sorry! I only removed the other variables from the code presented to you, to make it more readable! :-O "Time to give a Newtonian demonstration, of a bullet, its mass and its acceleration." -Stephen Hawking the gangsta rapper

        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