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. How to get detail error info from E_FAIL?

How to get detail error info from E_FAIL?

Scheduled Pinned Locked Moved C / C++ / MFC
c++comhelptutorialquestion
5 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.
  • F Offline
    F Offline
    Falconapollo
    wrote on last edited by
    #1

    When I use ATL in MFC Application(Don't ask me why, just because I like), sometimes I got the error code: E_FAIL. However, it's almost useless for me to locate the specific reason. I have googled so many times, but found nothing related. I thought there should be something like try{} catch{} in ATL. Here's some sample code:

    CAxWindow m_wndView; // ActiveX host window class.
    CComPtr m_spWMPPlayer; // Smart pointer to IWMPPlayer interface.

    AtlAxWinInit();
    CComPtr spHost;
    HRESULT hr;
    CRect rcClient;
    GetClientRect(&rcClient);
    m_wndView.Create(m_hWnd, rcClient, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);
    //when I switch to Static Link to ATL from Dynamic Link to ATL, I always get E_FAIL
    hr = m_wndView.QueryHost(&spHost);

    _ A 2 Replies Last reply
    0
    • F Falconapollo

      When I use ATL in MFC Application(Don't ask me why, just because I like), sometimes I got the error code: E_FAIL. However, it's almost useless for me to locate the specific reason. I have googled so many times, but found nothing related. I thought there should be something like try{} catch{} in ATL. Here's some sample code:

      CAxWindow m_wndView; // ActiveX host window class.
      CComPtr m_spWMPPlayer; // Smart pointer to IWMPPlayer interface.

      AtlAxWinInit();
      CComPtr spHost;
      HRESULT hr;
      CRect rcClient;
      GetClientRect(&rcClient);
      m_wndView.Create(m_hWnd, rcClient, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);
      //when I switch to Static Link to ATL from Dynamic Link to ATL, I always get E_FAIL
      hr = m_wndView.QueryHost(&spHost);

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      Use the _com_error class. Construct an object of this class by passing in the HRESULT value and then use its WCode or ErrorMessage methods to get the error code mapped to the HRESULT value.

      «_Superman_»  _I love work. It gives me something to do between weekends.

      _Microsoft MVP (Visual C++) (October 2009 - September 2013)

      Polymorphism in C

      F 1 Reply Last reply
      0
      • _ _Superman_

        Use the _com_error class. Construct an object of this class by passing in the HRESULT value and then use its WCode or ErrorMessage methods to get the error code mapped to the HRESULT value.

        «_Superman_»  _I love work. It gives me something to do between weekends.

        _Microsoft MVP (Visual C++) (October 2009 - September 2013)

        Polymorphism in C

        F Offline
        F Offline
        Falconapollo
        wrote on last edited by
        #3

        Thank you for your reply. I have did as what you said, but I only get the error message: Unspecified error. Here is my code:

        _com_error err(hr);
        auto d = err.WCode();
        auto s = err.Description();
        auto msg = err.ErrorMessage();//Unspecified error

        J 1 Reply Last reply
        0
        • F Falconapollo

          Thank you for your reply. I have did as what you said, but I only get the error message: Unspecified error. Here is my code:

          _com_error err(hr);
          auto d = err.WCode();
          auto s = err.Description();
          auto msg = err.ErrorMessage();//Unspecified error

          J Offline
          J Offline
          Jochen Arndt
          wrote on last edited by
          #4

          'Unspecified error' is the english error message for E_FAIL. There is no more information available.

          1 Reply Last reply
          0
          • F Falconapollo

            When I use ATL in MFC Application(Don't ask me why, just because I like), sometimes I got the error code: E_FAIL. However, it's almost useless for me to locate the specific reason. I have googled so many times, but found nothing related. I thought there should be something like try{} catch{} in ATL. Here's some sample code:

            CAxWindow m_wndView; // ActiveX host window class.
            CComPtr m_spWMPPlayer; // Smart pointer to IWMPPlayer interface.

            AtlAxWinInit();
            CComPtr spHost;
            HRESULT hr;
            CRect rcClient;
            GetClientRect(&rcClient);
            m_wndView.Create(m_hWnd, rcClient, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);
            //when I switch to Static Link to ATL from Dynamic Link to ATL, I always get E_FAIL
            hr = m_wndView.QueryHost(&spHost);

            A Offline
            A Offline
            Argonia
            wrote on last edited by
            #5

            You can try with GetLastError and see if you can get better description of the error . The number returned from the function you can check in msdn. Good luck :)

            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