Skip to content

Latest commit

 

History

History
72 lines (54 loc) · 3.17 KB

ole-initialization.md

File metadata and controls

72 lines (54 loc) · 3.17 KB
title ms.custom ms.date ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic f1_keywords dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author manager
OLE Initialization | Microsoft Docs
11/04/2016
cpp-windows
article
afxdisp/AfxOleInit
afxdisp/AfxEnableControlContainer
C++
OLE initialization
aa8a54a7-24c3-4344-b2c6-dbcf6084fa31
13
mikeblome
mblome
ghogen

OLE Initialization

Before an application can use OLE system services, it must initialize the OLE system DLLs and verify that the DLLs are the correct version. The AfxOleInit function initializes the OLE system DLLs.

OLE Initialization

AfxOleInit Initializes the OLE libraries.
AfxEnableControlContainer Call this function in your application object's InitInstance function to enable support for containment of OLE controls.

AfxEnableControlContainer

Call this function in your application object's InitInstance function to enable support for containment of OLE controls.

Syntax

void AfxEnableControlContainer( );  

Remarks

For more information about OLE controls (now called ActiveX controls), see ActiveX Control Topics.

Requirements

Header: afxdisp.h

AfxOleInit

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.

Remarks

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.

Note

MFC applications must be initialized as single threaded apartment (STA). If you call CoInitializeEx in your InitInstance override, specify COINIT_APARTMENTTHREADED (rather than COINIT_MULTITHREADED). For more information, see PRB: MFC Application Stops Responding When You Initialize the Application as a Multithreaded Apartment (828643) at http://support.microsoft.com/default.aspxscid=kb;en-us;828643.

Requirements

Header: afxdisp.h

See Also

Macros and Globals