#include <comstl/util/initialisers.hpp>
This class is used to initialise the COM libraries. It can respond to CoInitializeEx argument flags when translated in a DCOM build.
It is specialised for COM or OLE library initialisation, and with or without throwing an exception on failure, in the following typedefs:
It is commonly used within main() (for a CLI program), or WinMain() (for a GUI program). A typical program structure is shown as follows: 
#include <comstl/util/initialisers.hpp> #include <stdlib.h> static int main_(int argc, char **argv) { . . . // main application functionality } int main(int argc, char **argv) { try { comstl::com_init init; // Initialise the COM libraries return main_(argc, argv); } catch(comstl::com_initialisation_exception &x) // COM library initialisation failed { return EXIT_FAILURE; } catch(std::exception &x) // other failures from main_() { return EXIT_FAILURE; } }
In practice, initialisation failure of the COM libraries is unheard of, so you can probably dispense with the specific catch clause shown above, and rely on comstl::com_initialisation_exception being caught by the std::exception clause.
by_library/com_utility/creation_functions/creation_functions.cpp, by_library/com_utility/rot_functions/rot_functions.cpp, by_library/memory/com_memory_functions/com_memory_functions.cpp, and by_project/comstl/comstl.cpp.
| Member Types | |
| typedef IP | initialisation_policy_type | 
| The initialiation policy type. | |
| typedef XP | exception_policy_type | 
| The exception type. | |
| typedef exception_policy_type::thrown_type | thrown_type | 
| The thrown type. | |
| Public Member Functions | |
| Construction | |
| initialiser () | |
| Initialises via CoInitialize(). | |
| ~initialiser () throw () | |
| Uninitialises via CoUninitialize(). | |
| Attributes | |
| bool | is_initialised () const | 
| Reflects whether the COM libraries were initialised. | |
| bool | operator! () const | 
| Reflects whether the COM libraries were not initialised. | |
| HRESULT | get_HRESULT () const | 
| The result of the call to CoInitialize()/CoInitializeEx(). | |
| typedef IP initialisation_policy_type | 
The initialiation policy type.
| typedef XP exception_policy_type | 
The exception type.
| typedef exception_policy_type::thrown_type thrown_type | 
The thrown type.
| initialiser | ( | ) |  [inline] | 
Initialises via CoInitialize().
| ~initialiser | ( | ) | throw ()  [inline] | 
| bool is_initialised | ( | ) | const  [inline] | 
Reflects whether the COM libraries were initialised.
Referenced by initialiser::operator!(), and initialiser::~initialiser().
| bool operator! | ( | ) | const  [inline] | 
| HRESULT get_HRESULT | ( | ) | const  [inline] | 
The result of the call to CoInitialize()/CoInitializeEx().
 1.5.6
 1.5.6