CoInitializeEx

This function initializes the Component Object Model (COM) for use by the current thread. Applications are required to use CoInitializeEx before they make any other COM library calls except for memory allocation functions.

At a Glance

Header file: Objbase.h
Windows CE versions: 2.0 and later

Syntax

HRESULT CoInitializeEx(LPVOID pvReserved, DWORD dwCoInit);

Parameters

pvReserved

[in] Reserved; set to NULL.

dwCoInit

[in] Specifies the concurrency model and initialization options for the thread. Must be set to COINIT_MULTITHREADED.

Return Values

S_OK indicates that the COM library was initialized successfully. S_FALSE indicates that the COM library is already initialized. The standard return values E_INVALIDARG, E_OUTOFMEMORY, and E_UNEXPECTED are also supported.

Remarks

To close the COM library gracefully on a thread, each successful call to CoInitializeEx, including any call that returns S_FALSE, must be balanced by a corresponding call to CoUninitialize.

The CoInitializeEx function initializes the Component Object Model (COM), including the OLE library.

The dwCoInit parameter specifies the type of concurrency control required by objects created by this thread. Windows CE supports only the multi-threaded concurrency control. Thus, COINIT_MULTITHREADED is the only option permitted for the dwCoInit parameter.

Compound document applications must call CoInitializeEx before calling any other function in the OLE library.

Windows CE does not support the CoInitialize(NULL) or OleInitialize function. Use CoInitializeEx instead.

Passing into this function any invalid and, under some circumstances, NULL pointers result in unexpected termination of the application.