# OleInitialize

The OleInitialize function initializes the OLE library. You must initialize the library before you can call OLE functions.

WINOLEAPI OleInitialize(

LPVOID pvReserved | //Reserved
); |

Parameter

pvReserved
  [in] In 32-bit OLE, reserved; must be NULL. The 32-bit version of OLE does not support applications replacing OLE’s allocator and if the parameter is not NULL, OleInitialize returns E_INVALIDARG.

Return Values

This function supports the standard return values E_INVALIDARG, E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following:

S_OK
  The library was initialized successfully.
S_FALSE
  The OLE library is already initialized; a pointer to the IMalloc implementation was not used.
OLE_E_WRONGCOMPOBJ
  Indicates compobj.dll is the wrong version for ole2.dll.

Remarks

Compound document applications must call OleInitialize before calling any other function in the OLE library. OleInitialize calls the CoInitialize function internally.

Typically, OleInitialize is called only once in the process that uses the OLE library. There can be multiple calls, but subsequent calls return S_FALSE. To close the library gracefully, each successful call to OleInitialize, including those that return S_FALSE, must be balanced by a corresponding call to the OleUninitialize function.

See Also

OleUninitialize, CoInitialize