Index   Commented   Search   About

CoInitialize

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
);

Parameter

pvReserved

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

S_OK

Indicates the library was initialized successfully.

S_FALSE

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

E_OUTOFMEMORY

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

E_INVALIDARG

Indicates the argument is invalid.

E_UNEXPECTED

Indicates an unexpected error occurred.

Comments

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

Related Links

Software for Delphi and C++ Builder developers
Software for Visual Studio .NET developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET
TMS Scripter Studio Pro components for Delphi/C++Builder

More Online Helps

Win32 Programmer's Reference (win32.hlp)
Win32 Multimedia Programmer's Reference (mmedia.hlp)
Microsoft Windows Pen API Programmer's Reference (penapi.hlp)
Microsoft Windows Sockets 2 Reference (sock2.hlp)
Microsoft Windows Telephony API (TAPI) Programmer's Reference (sock2.hlp)
Unix Manual Pages

Free Tech Secrets ;) Copyright © 2008 Free Tect Secrets ;) greatis just4fun network just4fun