This documentation is archived and is not being maintained.


Initializes OLE support for the application.

BOOL AFXAPI AfxOleInit( );

Return Value

Nonzero if successful; 0 if initialization fails, possibly because incorrect versions of the OLE system DLLs are installed.


Call this function to initialize the OLE support for an MFC application. When this function is called, the following actions occur:

  • Initializes the COM library on the current apartment of the calling application. For more information, see OleInitialize.
  • Creates a message filter object, implementing the IMessageFilter interface. This message filter can be accessed with a call to AfxOleGetMessageFilter.
Note   If AfxOleInit is called from an MFC DLL, the call will fail. The failure occurs because the function assumes that, if it is called from a DLL, the OLE system was previously initialized by the calling application.

See Also

MFC Macros and Globals | AfxMessageBox