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. ATL / WTL / STL
  4. CoCreateInstance Problem & GetLastError 0x0000007e

CoCreateInstance Problem & GetLastError 0x0000007e

Scheduled Pinned Locked Moved ATL / WTL / STL
helpquestionannouncement
11 Posts 3 Posters 3 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.
  • Y yihung hung

    Hi All I have this call to CoCreateInstance that fails, and i get 0x0000007e from GetLastError. Has everybody allready had this kind of error ? Thank you. // import VoipTestCom.dll #pragma warning(disable:4146) #import "C:\workvs2008\binaries\Win32\Release\bin\VoipTestCom.dll" raw_interfaces_only, raw_native_types, no_namespace, named_guids LRESULT CSTapiCom::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { ISimpleClientPtr m_sipclicom; CAxWindow wnd; CLSID clsid; LPUNKNOWN pUnkCtrl, pUnkCont; HRESULT hr = CLSIDFromProgID(OLESTR("VoipTestCom.SimpleClient"), &clsid); if (hr == S_OK ) { ::MessageBox(NULL, _T("CLSIDFromProgID...ok"), _T("INFO"), MB_OK); } hr = CoCreateInstance(clsid, NULL, CLSCTX_ALL, IID_IUnknown, (void**)&pUnkCtrl); if (hr == S_OK ) { ::MessageBox(NULL, _T("CoCreateInstance...ok"), _T("INFO"), MB_OK); } else { TCHAR szBuff[64]; swprintf(szBuff, L"CoCreateInstance...fail->%x",GetLastError()); ::MessageBox(NULL, szBuff, _T("INFO"), MB_OK); } return TRUE; }

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #2

    What was the status returned from the call to CoCreateInstance?

    Use the best guess

    Y 1 Reply Last reply
    0
    • L Lost User

      What was the status returned from the call to CoCreateInstance?

      Use the best guess

      Y Offline
      Y Offline
      yihung hung
      wrote on last edited by
      #3

      i get 0x0000007e from GetLastError

      L 1 Reply Last reply
      0
      • Y yihung hung

        i get 0x0000007e from GetLastError

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #4

        According to the documentation[^] that is equivalent to ERROR_MOD_NOT_FOUND which means it cannot find the file containing the COM class.

        Use the best guess

        Y 1 Reply Last reply
        0
        • Y yihung hung

          Hi All I have this call to CoCreateInstance that fails, and i get 0x0000007e from GetLastError. Has everybody allready had this kind of error ? Thank you. // import VoipTestCom.dll #pragma warning(disable:4146) #import "C:\workvs2008\binaries\Win32\Release\bin\VoipTestCom.dll" raw_interfaces_only, raw_native_types, no_namespace, named_guids LRESULT CSTapiCom::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { ISimpleClientPtr m_sipclicom; CAxWindow wnd; CLSID clsid; LPUNKNOWN pUnkCtrl, pUnkCont; HRESULT hr = CLSIDFromProgID(OLESTR("VoipTestCom.SimpleClient"), &clsid); if (hr == S_OK ) { ::MessageBox(NULL, _T("CLSIDFromProgID...ok"), _T("INFO"), MB_OK); } hr = CoCreateInstance(clsid, NULL, CLSCTX_ALL, IID_IUnknown, (void**)&pUnkCtrl); if (hr == S_OK ) { ::MessageBox(NULL, _T("CoCreateInstance...ok"), _T("INFO"), MB_OK); } else { TCHAR szBuff[64]; swprintf(szBuff, L"CoCreateInstance...fail->%x",GetLastError()); ::MessageBox(NULL, szBuff, _T("INFO"), MB_OK); } return TRUE; }

          S Offline
          S Offline
          Stephen Hewitt
          wrote on last edited by
          #5

          The obvious question is: did you initialise COM?

          Steve

          Y 1 Reply Last reply
          0
          • L Lost User

            According to the documentation[^] that is equivalent to ERROR_MOD_NOT_FOUND which means it cannot find the file containing the COM class.

            Use the best guess

            Y Offline
            Y Offline
            yihung hung
            wrote on last edited by
            #6

            Here is the VoipTestCom_i.c & VoipTestCom.idl code I used to call the object. The object is nammed SimpleClient and the method I call is nammed TestOnRegisterStatusChanged(). I want to use ATL component into my Composite Control(CYHtapiCom) in C++ with ATL. When i test this code on my atl control. I am getting the error: CoCreateInstance failed 0x0000007e. How to add VoipTestCom controls to an ATL composite control programmatically in Visual C++? Thank you. 1. LRESULT CYHtapiCom::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { CAxWindow wnd; CLSID clsid; LPUNKNOWN pUnkCtrl, pUnkCont; HRESULT hr = CLSIDFromProgID(OLESTR("VoipTestCom.SimpleClient"), &clsid); hr = CoCreateInstance(clsid, NULL, CLSCTX_ALL, IID_IUnknown, (void**)&pUnkCtrl); CComQIPtr spPerStm(pUnkCtrl); spPerStm->InitNew(); wnd.Attach(m_hWnd); wnd.AttachControl(pUnkCtrl, &pUnkCont); return TRUE; } 2.VoipTestCom_i.c /* this ALWAYS GENERATED file contains the IIDs and CLSIDs */ /* link this file in with the server and any clients */ /* File created by MIDL compiler version 7.00.0500 */ /* at Sat Apr 06 21:40:37 2013 */ /* Compiler settings for .\VoipTestCom.idl: Oicf, W1, Zp8, env=Win32 (32b run) protocol : dce , ms_ext, c_ext, robust error checks: stub_data VC __declspec() decoration level: __declspec(uuid()), __declspec(selectany), __declspec(novtable) DECLSPEC_UUID(), MIDL_INTERFACE() */ //@@MIDL_FILE_HEADING( ) #pragma warning( disable: 4049 ) /* more than 64k source lines */ #ifdef __cplusplus extern "C"{ #endif #include #include #ifdef _MIDL_USE_GUIDDEF_ #ifndef INITGUID #define INITGUID #include #undef INITGUID #else #include #endif #define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \ DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) #else // !_MIDL_USE_GUIDDEF_ #ifndef __IID_DEFINED__ #define __IID_DEFINED__ typedef struct _IID { unsigned long x; unsigned short s1; unsigned short s2; unsigned char c[8]; } IID; #endif // __IID_DEFINED__ #ifndef CLSID_DEFINED #define CLSID_DEFINED typedef IID CLSID; #endif // CLSID_DEFINED #define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \ const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}} #endif !_MIDL_USE_GUIDDEF_ MIDL_DEFINE_GUID(IID, IID_ISimpleClient,0x5CA1C162,0x671E,0x4EE8,0x98,0x75,0x27,0x7F,0x4E,0xF1,0xE8,0xCE); MIDL_DEFINE_GUID(I

            L 1 Reply Last reply
            0
            • S Stephen Hewitt

              The obvious question is: did you initialise COM?

              Steve

              Y Offline
              Y Offline
              yihung hung
              wrote on last edited by
              #7

              CoInitialize? Where do I add the CoInitialize?

              S L 2 Replies Last reply
              0
              • Y yihung hung

                CoInitialize? Where do I add the CoInitialize?

                S Offline
                S Offline
                Stephen Hewitt
                wrote on last edited by
                #8

                Somewhere before you use COM.

                Steve

                Y 1 Reply Last reply
                0
                • Y yihung hung

                  Here is the VoipTestCom_i.c & VoipTestCom.idl code I used to call the object. The object is nammed SimpleClient and the method I call is nammed TestOnRegisterStatusChanged(). I want to use ATL component into my Composite Control(CYHtapiCom) in C++ with ATL. When i test this code on my atl control. I am getting the error: CoCreateInstance failed 0x0000007e. How to add VoipTestCom controls to an ATL composite control programmatically in Visual C++? Thank you. 1. LRESULT CYHtapiCom::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { CAxWindow wnd; CLSID clsid; LPUNKNOWN pUnkCtrl, pUnkCont; HRESULT hr = CLSIDFromProgID(OLESTR("VoipTestCom.SimpleClient"), &clsid); hr = CoCreateInstance(clsid, NULL, CLSCTX_ALL, IID_IUnknown, (void**)&pUnkCtrl); CComQIPtr spPerStm(pUnkCtrl); spPerStm->InitNew(); wnd.Attach(m_hWnd); wnd.AttachControl(pUnkCtrl, &pUnkCont); return TRUE; } 2.VoipTestCom_i.c /* this ALWAYS GENERATED file contains the IIDs and CLSIDs */ /* link this file in with the server and any clients */ /* File created by MIDL compiler version 7.00.0500 */ /* at Sat Apr 06 21:40:37 2013 */ /* Compiler settings for .\VoipTestCom.idl: Oicf, W1, Zp8, env=Win32 (32b run) protocol : dce , ms_ext, c_ext, robust error checks: stub_data VC __declspec() decoration level: __declspec(uuid()), __declspec(selectany), __declspec(novtable) DECLSPEC_UUID(), MIDL_INTERFACE() */ //@@MIDL_FILE_HEADING( ) #pragma warning( disable: 4049 ) /* more than 64k source lines */ #ifdef __cplusplus extern "C"{ #endif #include #include #ifdef _MIDL_USE_GUIDDEF_ #ifndef INITGUID #define INITGUID #include #undef INITGUID #else #include #endif #define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \ DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) #else // !_MIDL_USE_GUIDDEF_ #ifndef __IID_DEFINED__ #define __IID_DEFINED__ typedef struct _IID { unsigned long x; unsigned short s1; unsigned short s2; unsigned char c[8]; } IID; #endif // __IID_DEFINED__ #ifndef CLSID_DEFINED #define CLSID_DEFINED typedef IID CLSID; #endif // CLSID_DEFINED #define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \ const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}} #endif !_MIDL_USE_GUIDDEF_ MIDL_DEFINE_GUID(IID, IID_ISimpleClient,0x5CA1C162,0x671E,0x4EE8,0x98,0x75,0x27,0x7F,0x4E,0xF1,0xE8,0xCE); MIDL_DEFINE_GUID(I

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #9

                  You don't really think I can read through all that and come to a sensible conclusion?

                  Use the best guess

                  1 Reply Last reply
                  0
                  • Y yihung hung

                    CoInitialize? Where do I add the CoInitialize?

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #10

                    Have you not read http://msdn.microsoft.com/en-us/library/ms886306.aspx[^]?

                    Use the best guess

                    1 Reply Last reply
                    0
                    • S Stephen Hewitt

                      Somewhere before you use COM.

                      Steve

                      Y Offline
                      Y Offline
                      yihung hung
                      wrote on last edited by
                      #11

                      LRESULT CYHtapiCom::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { CAxWindow wnd; CLSID clsid; LPUNKNOWN pUnkCtrl, pUnkCont; HRESULT hr = CLSIDFromProgID(OLESTR("VoipTestCom.SimpleClient"), &clsid); hr = CoCreateInstance(clsid, NULL, CLSCTX_ALL, IID_IUnknown, (void**)&pUnkCtrl); CComQIPtr spPerStm(pUnkCtrl); spPerStm->InitNew(); wnd.Attach(m_hWnd); wnd.AttachControl(pUnkCtrl, &pUnkCont); return TRUE; }

                      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