OleInitialize

From aldeid
Jump to navigation Jump to search

Description

Used to initialize the COM library. Programs that use COM objects must call OleInitialize prior to calling any other COM functions.

Applications that use the following functionality must call OleInitialize before calling any other function in the COM library:

  • Clipboard
  • Drag and Drop
  • Object linking and embedding (OLE)
  • In-place activation

OleInitialize calls CoInitializeEx internally to initialize the COM library on the current apartment. Because OLE operations are not thread-safe, OleInitialize specifies the concurrency model as single-thread apartment.

Syntax

HRESULT OleInitialize(
  _In_  LPVOID pvReserved
);

Parameters

pvReserved [in]
This parameter is reserved and must be NULL.

Return value

This function returns S_OK on success. Other possible values include the following.

Return code Description
S_FALSE The COM library is already initialized on this apartment.
OLE_E_WRONGCOMPOBJ The versions of COMPOBJ.DLL and OLE2.DLL on your machine are incompatible with each other.
RPC_E_CHANGED_MODE A previous call to CoInitializeEx specified the concurrency model for this apartment as multithread apartment (MTA). This could also mean that a change from neutral threaded apartment to single threaded apartment occurred.