ComInitializeEx
f90VB Modules
f90VBDefs, f90VBAutomation
Summary
Initializes the COM library on the current thread, sets the thread's concurrency model, and creates a new apartment for the thread if one is required.
Syntax
| integer(HRESULT_KIND) function ComInitialize | (Flags) |
| integer(DWORD_KIND),intent(in):: | Flags |
Arguments
Flags [Input]
Flags specifying the concurrency model and initialization options for the thread. See comments for description of allowed values.
Comments
Applications must initialize the COM library before they can call other functions from the f90VBAutomation library. The preferred method to initialize the COM library when using f90VBAutomation is by calling OleInitialize, rather than ComInitializeEx. OleInitialize internally calls ComInitializeEx with the appropriate arguments.
ComInitializeEx can return any of the following values:
| Return Value | Description | |
| S_OK | The COM library was successfully initialized on this thread | |
| E_OUTOFMEMORY | COM library was not initialized because of lack of memory | |
| E_UNEXPECTED | An unexpected error occurred. | |
| S_FALSE | The COM library is already initialized on this thread | |
| RPC_E_CHANGED_MODE | A previous call to ComInitializeEx specified the concurrency model for this thread as multithread apartment (MTA). | |
Calls to ComInitializeEx must be paired with calls to ComUninitialize (i.e. your program must issue a call to ComUninitialize for each call to ComInitialize). Calls to ComInitializeEx and OleInitialize can be nested.
Argument Flags
Any combination of the values indicated below can be used, except that the COINIT_APARTMENTTHREADED and COINIT_MULTITHREADED cannot be used together.
| Argument Flags | Description | |
| COINIT_MULTITHREADED | Initializes the thread for multi-threaded object concurrency | |
| COINIT_APARTMENTTHREADED | Initializes the thread for apartment-threaded object concurrency | |
| COINIT_DISABLE_OLE1DDE | Disables DDE for Ole1 support | |
| COINIT_SPEED_OVER_MEMORY | Trades memory for speed | |
Related Topics
| For information about: | See: | |
| Initializing the COM Library | ComInitializeEx | |
| Uninitializing the COM library | ComUninitialize | |
| Initializing the OLE Library | OleInitialize | |
| Uninitializing the OLE library | OleUninitialize | |