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 with two exceptions: the CoGetMalloc function, and memory allocation calls.

HRESULT CoInitialize(

LPVOID pvReserved
//Reserved, must be NULL



In 32-bit OLE, this parameter must be NULL. The 32-bit version of OLE does not support applications replacing OLE's allocator and if the parameter is not NULL, CoInitialize returns E_INVALIDARG.

Return Values


Indicates the library was initialized successfully.


Indicates that the library is already initialized or that it could not release default allocator.


Indicates that it was unable to initialize because the system is out of memory.


Indicates the argument is invalid.


Indicates an unexpected error occurred.


You need to call this before you call any of the OLE library functions 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 the CoUninitialize function.

See Also

CoInitialize, OleInitialize

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database