sbAutoCOMInitializer Class Reference

#include <sbAutoCOMInitializer.h>

Public Member Functions

 sbAutoCOMInitializer (DWORD aInitFlags)
 
 sbAutoCOMInitializer ()
 
 ~sbAutoCOMInitializer ()
 
HRESULT Initialize (DWORD aInitFlags=COINIT_MULTITHREADED)
 
void Uninitialize ()
 
HRESULT GetHRESULT () const
 
bool Succeeded () const
 
bool Initialized () const
 

Public Attributes

int mInitialized
 
HRESULT mFailureResult
 
DWORD mInitThreadId
 

Detailed Description

This class manages COM Initialization and uninitialization. You can use the constructor to initialize and destructor to uninitialize COM. Or you can use the Initialize and Uninitialize methods to manually manage. This class should be owned by a single thread and should never be called from multiple threads.

Definition at line 42 of file sbAutoCOMInitializer.h.

Constructor & Destructor Documentation

sbAutoCOMInitializer::sbAutoCOMInitializer ( DWORD  aInitFlags)
inline

Initializes COM on construction

Definition at line 48 of file sbAutoCOMInitializer.h.

Here is the call graph for this function:

sbAutoCOMInitializer::sbAutoCOMInitializer ( )
inline

Initializes the object, but does not initialize COM. Iniialize must be called

Definition at line 57 of file sbAutoCOMInitializer.h.

sbAutoCOMInitializer::~sbAutoCOMInitializer ( )
inline

Uninitializes COM on destruction of the object if COM has been initialized

Definition at line 66 of file sbAutoCOMInitializer.h.

Here is the call graph for this function:

Member Function Documentation

HRESULT sbAutoCOMInitializer::GetHRESULT ( ) const
inline

Returns the HRESULT failure code that was returned from CoInitializeEx RPC_E_CHANGED_MODE is never returned as it's considered success.

Definition at line 142 of file sbAutoCOMInitializer.h.

HRESULT sbAutoCOMInitializer::Initialize ( DWORD  aInitFlags = COINIT_MULTITHREADED)
inline

Initializes COM. You may call this multiple times, it keeps track internally and only initializes COM on the first call. You MUST call Uninitialize for each extra call to Initialize in order for COM to be property uninitialized.

Definition at line 84 of file sbAutoCOMInitializer.h.

Here is the caller graph for this function:

bool sbAutoCOMInitializer::Initialized ( ) const
inline

Definition at line 156 of file sbAutoCOMInitializer.h.

Here is the caller graph for this function:

bool sbAutoCOMInitializer::Succeeded ( ) const
inline

Determines whether initialization was successful. NOTE: Already initialized error where a different thread model was specified is considered success.

Definition at line 151 of file sbAutoCOMInitializer.h.

void sbAutoCOMInitializer::Uninitialize ( )
inline

Called to uninitialize COM. Will uninitialze on the last call that matches the first call to Initialize.

Definition at line 119 of file sbAutoCOMInitializer.h.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

HRESULT sbAutoCOMInitializer::mFailureResult

The HRESULT that CoInitializeEx returned.

Definition at line 170 of file sbAutoCOMInitializer.h.

int sbAutoCOMInitializer::mInitialized

Tracks whether and how many times the COM initialization has been requested.

Definition at line 165 of file sbAutoCOMInitializer.h.

DWORD sbAutoCOMInitializer::mInitThreadId

The thread ID of the thread that called Initialize. Used to ensure we call CoUninitialize on the same thread.

Definition at line 176 of file sbAutoCOMInitializer.h.


The documentation for this class was generated from the following file: