Knowledge Base

CoInitialize() May Cause OLE Applications to Stop Responding

Article ID: 159273

Article Last Modified on 4/13/2004


APPLIES TO


This article was previously published under Q159273

SYMPTOMS

After a Windows OLE application (such as Date/Time in Control Panel) issues a SendMessage(HWND_BRAODCAST) to a console application, the Windows OLE application appears to stop responding.

CAUSE

The console application does not have a Windows message loop.

If a console application calls CoInitialize() to initialize the Component Object Model (COM) library, it does not have a Windows message queue. This causes OLE applications to stop responding while they are waiting for the console application to process their messages. The basic assumption with OLE is that OLE applications are Windows applications, and that they process messages on a regular basis.

WORKAROUND

To work around this problem, do either of the following:
  • Make sure your console application has an active Windows message loop.

    -or-
  • In Windows NT 4.0, instead of using CoIninitialize(), write your code to call CoInitializeEx(NULL, COINIT_MULTITHREADED), which does not use Windows messages for object remote procedure calls (RPCs).

Additional query words: prodnt prodsna 2.11 hang hung crash fail RPC call

Keywords: kbinterop kbnetwork kbprb KB159273