The CoInitialize function initializes the Component Object Model(COM) library. You must initialize the library before you can call its functions. Applications must call CoInitialize before they make any other COM library calls except the CoGetMalloc function and memory allocation calls.
HRESULT CoInitialize(
LPVOID pvReserved |
//Reserved, must be NULL |
); |
Parameter
Return Values
This function supports the standard return values E_INVALIDARG, E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following:
Remarks
You need to call this before you call any of the OLE library functions (except CoGetMalloc, to get a pointer to the standard allocator, and the memory allocation functions and methods) unless you call the OleInitialize function, which calls CoInitialize internally.
Typically, CoInitialize 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 CoInitialize, including those that return S_FALSE, must be balanced by a corresponding call to its companion helper function, CoUninitialize.
See Also
CoUninitialize, OleInitialize, Processes and Threads