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. Failed to initialize COM library error

Failed to initialize COM library error

Scheduled Pinned Locked Moved C / C++ / MFC
helpvisual-studiocomquestion
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.
  • L Offline
    L Offline
    Le rner
    wrote on last edited by
    #1

    Hi all, I have made a exe using VS-2008. I am trying to run that exe on another pc which not having VS-2008 inatalled on it (having OS - win xp with sp3), in my exe i have initialised COM using this code.

    hres = CoInitializeEx(0, COINIT_MULTITHREADED);
    if (FAILED(hres))
    {
    AfxMessageBox(_T("Failed to initialize COM library") );
    return; // Program has failed.
    }

    But every time i run my exe on this machine it gives "Failed to initialize COM library". Do i need to install anything extra on this machine... Or what other problem there might be? Can anybody help me in this... Thanks in advance

    To accomplish great things, we must not only act, but also dream; not only plan, but also believe.

    CPalliniC D T 3 Replies Last reply
    0
    • L Le rner

      Hi all, I have made a exe using VS-2008. I am trying to run that exe on another pc which not having VS-2008 inatalled on it (having OS - win xp with sp3), in my exe i have initialised COM using this code.

      hres = CoInitializeEx(0, COINIT_MULTITHREADED);
      if (FAILED(hres))
      {
      AfxMessageBox(_T("Failed to initialize COM library") );
      return; // Program has failed.
      }

      But every time i run my exe on this machine it gives "Failed to initialize COM library". Do i need to install anything extra on this machine... Or what other problem there might be? Can anybody help me in this... Thanks in advance

      To accomplish great things, we must not only act, but also dream; not only plan, but also believe.

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      You should check better the function return value (make your program reporting it). See the documentation for details [^]. :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      In testa che avete, signor di Ceprano?

      1 Reply Last reply
      0
      • L Le rner

        Hi all, I have made a exe using VS-2008. I am trying to run that exe on another pc which not having VS-2008 inatalled on it (having OS - win xp with sp3), in my exe i have initialised COM using this code.

        hres = CoInitializeEx(0, COINIT_MULTITHREADED);
        if (FAILED(hres))
        {
        AfxMessageBox(_T("Failed to initialize COM library") );
        return; // Program has failed.
        }

        But every time i run my exe on this machine it gives "Failed to initialize COM library". Do i need to install anything extra on this machine... Or what other problem there might be? Can anybody help me in this... Thanks in advance

        To accomplish great things, we must not only act, but also dream; not only plan, but also believe.

        D Offline
        D Offline
        Durga_Devi
        wrote on last edited by
        #3

        HI, For the function CoInitializeEx(), dont check for the returned code. Because if the COM has been initialized on the calling thread, the return code will be failed i.e S_FALSE. Just call the CoInitializeEx() and proceed to next.

        CPalliniC 1 Reply Last reply
        0
        • D Durga_Devi

          HI, For the function CoInitializeEx(), dont check for the returned code. Because if the COM has been initialized on the calling thread, the return code will be failed i.e S_FALSE. Just call the CoInitializeEx() and proceed to next.

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #4

          DurgaDevi_hr wrote:

          For the function CoInitializeEx(), dont check for the returned code. Because if the COM has been initialized on the calling thread, the return code will be failed i.e S_FALSE.

          Your point is wrong. In fact, CoInitializeEx() may return S_FALSE the way you depicted. However FAILED(S_FALSE) evaluates to false. :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          In testa che avete, signor di Ceprano?

          1 Reply Last reply
          0
          • L Le rner

            Hi all, I have made a exe using VS-2008. I am trying to run that exe on another pc which not having VS-2008 inatalled on it (having OS - win xp with sp3), in my exe i have initialised COM using this code.

            hres = CoInitializeEx(0, COINIT_MULTITHREADED);
            if (FAILED(hres))
            {
            AfxMessageBox(_T("Failed to initialize COM library") );
            return; // Program has failed.
            }

            But every time i run my exe on this machine it gives "Failed to initialize COM library". Do i need to install anything extra on this machine... Or what other problem there might be? Can anybody help me in this... Thanks in advance

            To accomplish great things, we must not only act, but also dream; not only plan, but also believe.

            T Offline
            T Offline
            transoft
            wrote on last edited by
            #5

            Did you register COM in the new machine? Using following function always successes for me.

            hr = CoCreateInstance( CLSID_App, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (void **) &pUnk );

            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