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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. unhandled exeption in a.exe(apiocx):0xc0000005 Access Violation

unhandled exeption in a.exe(apiocx):0xc0000005 Access Violation

Scheduled Pinned Locked Moved C / C++ / MFC
14 Posts 4 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.
  • P prasad_som

    With_problem wrote:

    while using this code....unhandled exeption in a.exe(apiocx):0xc0000005 Access Violation

    At which line ? Have you checked pointers for NULL before using ?

    With_problem wrote:

    if(hresult != NULL)

    HRESULT should use this way. Use SUCCEEDED(hresult) instead. i.e

    if(SUCCEEDED(hresult))
    {
    }

    Prasad Notifier using ATL | Operator new[],delete[][^]

    W Offline
    W Offline
    With_problem
    wrote on last edited by
    #3

    when it comes to setquotetodb function it gives error...i just dont know what to do,i have given my 100%....pls help me

    P 1 Reply Last reply
    0
    • P prasad_som

      With_problem wrote:

      while using this code....unhandled exeption in a.exe(apiocx):0xc0000005 Access Violation

      At which line ? Have you checked pointers for NULL before using ?

      With_problem wrote:

      if(hresult != NULL)

      HRESULT should use this way. Use SUCCEEDED(hresult) instead. i.e

      if(SUCCEEDED(hresult))
      {
      }

      Prasad Notifier using ATL | Operator new[],delete[][^]

      W Offline
      W Offline
      With_problem
      wrote on last edited by
      #4

      i have change my code also to laod dll.....now what to do....you have hepled me before also...thank you

      1 Reply Last reply
      0
      • W With_problem

        when it comes to setquotetodb function it gives error...i just dont know what to do,i have given my 100%....pls help me

        P Offline
        P Offline
        prasad_som
        wrote on last edited by
        #5

        t , how it is declared? It seems to be NULL in your case.

        With_problem wrote:

        ,i have given my 100%.

        You need to be very precise, while stating probem. Otherwisea, it will be unsolved forever.

        Prasad Notifier using ATL | Operator new[],delete[][^]

        W 1 Reply Last reply
        0
        • W With_problem

          while using this code....unhandled exeption in a.exe(apiocx):0xc0000005 Access Violation any solution

          HRESULT hresult;
          CLSID clsid;
          
          CoInitialize(NULL);
          hresult=CLSIDFromProgID(OLESTR("WartzODLCOM.DBAccess"),&clsid);
              \_DBAccess \*t;
          hresult=CoCreateInstance(clsid,NULL,CLSCTX\_INPROC\_SERVER,\_\_uuidof(IDispatch ),(LPVOID \*) &t);
          
          if(FAILED(hresult))
          {
          AfxMessageBox("Creation Failed");
          return;
          }
          
          else
          {
          MessageBox("success");
          }
          
          SessID=SessionId;
          CurrentRequestId=RequestId;
          
          marketno.Format("%d",MarketNo);
          bid\_d.Format("%c",BidDirection);
          ask\_d.Format("%c",AskDirection);
          marketstate.Format("%d",MarketState);
          
              m\_MainEdit= SessionId  + RequestId + marketno ; 
          m\_MainEdit=Market +  Bid + bid\_d + Ask + ask\_d + High 
          m\_MainEdit= Low  + marketstate  + Timestamp ;
          UpdateData(FALSE);
          iLineCount=m\_EditCtrl.GetLineCount();
          m\_EditCtrl.LineScroll(iLineCount);
          

          if(hresult != NULL)
          {
          USES_CONVERSION;
          BSTR bsTimeStamp = A2BSTR(Timestamp);
          BSTR bsMarket = A2BSTR(Market);
          BSTR bsBid = A2BSTR(Bid);
          BSTR bsAsk = A2BSTR(Ask);

          t->setQuoteToDB(&bsTimeStamp,&MarketNo,&bsMarket,&bsAsk,&bsBid,&MarketState);
          SysFreeString(bsTimeStamp);
          SysFreeString(bsMarket);
          SysFreeString(bsBid);
          SysFreeString(bsAsk);
          }
          else
          {
          MessageBox("null");
          }
          FreeLibrary( hInstance );

          CoUninitialize();
          
          return;
          }
          
          S Offline
          S Offline
          S Douglas
          wrote on last edited by
          #6

          With_problem wrote:

          t->setQuoteToDB(&bsTimeStamp,&MarketNo,&bsMarket,&bsAsk,&bsBid,&MarketState);
          when it comes to setquotetodb function it gives error

          Is this a COM DLL written in VB? If that is the case then the issue I believe would have more to do with the translation between the string types. I have gone the other way and had issues ie passing strings from a VB app to a C++ dll. If thats true try using LPSTR (from memory, but it just seems wrong) string instead of BSTR I only ask this because a Google search reviled this link Calling a VB ActiveX DLL from a MFC Client[^]


          I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:

          W 1 Reply Last reply
          0
          • P prasad_som

            t , how it is declared? It seems to be NULL in your case.

            With_problem wrote:

            ,i have given my 100%.

            You need to be very precise, while stating probem. Otherwisea, it will be unsolved forever.

            Prasad Notifier using ATL | Operator new[],delete[][^]

            W Offline
            W Offline
            With_problem
            wrote on last edited by
            #7

            can you pls point me wher i am making big mistake....pls when i use this code it also give error error C2787: '_DBAccess' : no GUID has been associated with this object hresult=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,__uuidof(_DBAccess),(LPVOID *) &t); But i have seen in .tlh file clsid is attach with this ....

            S 1 Reply Last reply
            0
            • S S Douglas

              With_problem wrote:

              t->setQuoteToDB(&bsTimeStamp,&MarketNo,&bsMarket,&bsAsk,&bsBid,&MarketState);
              when it comes to setquotetodb function it gives error

              Is this a COM DLL written in VB? If that is the case then the issue I believe would have more to do with the translation between the string types. I have gone the other way and had issues ie passing strings from a VB app to a C++ dll. If thats true try using LPSTR (from memory, but it just seems wrong) string instead of BSTR I only ask this because a Google search reviled this link Calling a VB ActiveX DLL from a MFC Client[^]


              I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:

              W Offline
              W Offline
              With_problem
              wrote on last edited by
              #8

              thanks i have used the same link to proceed with....but still facng the problem....after #import dll when i use namespace it report the error....why...

              S 1 Reply Last reply
              0
              • W With_problem

                thanks i have used the same link to proceed with....but still facng the problem....after #import dll when i use namespace it report the error....why...

                S Offline
                S Offline
                S Douglas
                wrote on last edited by
                #9

                With_problem wrote:

                it report the error

                Which error? Access Violation?


                I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:

                W 1 Reply Last reply
                0
                • W With_problem

                  can you pls point me wher i am making big mistake....pls when i use this code it also give error error C2787: '_DBAccess' : no GUID has been associated with this object hresult=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,__uuidof(_DBAccess),(LPVOID *) &t); But i have seen in .tlh file clsid is attach with this ....

                  S Offline
                  S Offline
                  S Douglas
                  wrote on last edited by
                  #10

                  With_problem wrote:

                  no GUID has been associated with this object

                  Google to the rescue Google to the rescue [^] Try the second link.


                  I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:

                  1 Reply Last reply
                  0
                  • W With_problem

                    while using this code....unhandled exeption in a.exe(apiocx):0xc0000005 Access Violation any solution

                    HRESULT hresult;
                    CLSID clsid;
                    
                    CoInitialize(NULL);
                    hresult=CLSIDFromProgID(OLESTR("WartzODLCOM.DBAccess"),&clsid);
                        \_DBAccess \*t;
                    hresult=CoCreateInstance(clsid,NULL,CLSCTX\_INPROC\_SERVER,\_\_uuidof(IDispatch ),(LPVOID \*) &t);
                    
                    if(FAILED(hresult))
                    {
                    AfxMessageBox("Creation Failed");
                    return;
                    }
                    
                    else
                    {
                    MessageBox("success");
                    }
                    
                    SessID=SessionId;
                    CurrentRequestId=RequestId;
                    
                    marketno.Format("%d",MarketNo);
                    bid\_d.Format("%c",BidDirection);
                    ask\_d.Format("%c",AskDirection);
                    marketstate.Format("%d",MarketState);
                    
                        m\_MainEdit= SessionId  + RequestId + marketno ; 
                    m\_MainEdit=Market +  Bid + bid\_d + Ask + ask\_d + High 
                    m\_MainEdit= Low  + marketstate  + Timestamp ;
                    UpdateData(FALSE);
                    iLineCount=m\_EditCtrl.GetLineCount();
                    m\_EditCtrl.LineScroll(iLineCount);
                    

                    if(hresult != NULL)
                    {
                    USES_CONVERSION;
                    BSTR bsTimeStamp = A2BSTR(Timestamp);
                    BSTR bsMarket = A2BSTR(Market);
                    BSTR bsBid = A2BSTR(Bid);
                    BSTR bsAsk = A2BSTR(Ask);

                    t->setQuoteToDB(&bsTimeStamp,&MarketNo,&bsMarket,&bsAsk,&bsBid,&MarketState);
                    SysFreeString(bsTimeStamp);
                    SysFreeString(bsMarket);
                    SysFreeString(bsBid);
                    SysFreeString(bsAsk);
                    }
                    else
                    {
                    MessageBox("null");
                    }
                    FreeLibrary( hInstance );

                    CoUninitialize();
                    
                    return;
                    }
                    
                    R Offline
                    R Offline
                    Rudolf Jan
                    wrote on last edited by
                    #11

                    The error normally indicates that you did something that cause your program to access memory that does not belong to your program. Normally this is caused by an invalid pointer, or by arrays exceeding bounds. The problem may become obvious at a completely other location than the location where you caused teh problem. My recommendation: use the debugger to check the contents of all variables for wrong or invalid values. Maybe you can comment out sections of your application to make bug hunting easer. It is very unlikely that someone on the Internet will provide you the solution. Good luck

                    1 Reply Last reply
                    0
                    • S S Douglas

                      With_problem wrote:

                      it report the error

                      Which error? Access Violation?


                      I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:

                      W Offline
                      W Offline
                      With_problem
                      wrote on last edited by
                      #12

                      error C2872: '_DBAccess' : ambiguous symbol

                      1 Reply Last reply
                      0
                      • P prasad_som

                        With_problem wrote:

                        while using this code....unhandled exeption in a.exe(apiocx):0xc0000005 Access Violation

                        At which line ? Have you checked pointers for NULL before using ?

                        With_problem wrote:

                        if(hresult != NULL)

                        HRESULT should use this way. Use SUCCEEDED(hresult) instead. i.e

                        if(SUCCEEDED(hresult))
                        {
                        }

                        Prasad Notifier using ATL | Operator new[],delete[][^]

                        W Offline
                        W Offline
                        With_problem
                        wrote on last edited by
                        #13

                        hello som you have helped me a lot to solve my problem....i just mail you here to say thank you very much for your support and help...for coding and corresction... And yes one more thing this error is just no more when i have used the try,catch block.....and now my project is working fine.... Haappy New Year Regards Priyanka

                        P 1 Reply Last reply
                        0
                        • W With_problem

                          hello som you have helped me a lot to solve my problem....i just mail you here to say thank you very much for your support and help...for coding and corresction... And yes one more thing this error is just no more when i have used the try,catch block.....and now my project is working fine.... Haappy New Year Regards Priyanka

                          P Offline
                          P Offline
                          prasad_som
                          wrote on last edited by
                          #14

                          You are always welcome. Happy New Year to you,too.

                          Prasad Notifier using ATL | Operator new[],delete[][^]

                          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