xentara-utils v1.2.1
Xentara utilities library
Loading...
Searching...
No Matches
xentara::utils::windows::com Namespace Reference

Windows COM functionality. More...

Namespaces

namespace  variantTypes
 Namespace containing Windows COM variant types.
 

Classes

class  Exception
 An exception that wraps an IErrorInfo COM object. More...
 
class  ObjectHandle
 A handle to a COM object. More...
 
class  String
 An COM string object. More...
 
class  ThreadEnvironment
 A class that initializes the COM interface. More...
 
class  Variant
 A COM variant object. More...
 

Functions

auto throwError (HRESULT result, const std::string &message) -> void
 Throws an exception after a COM error.
 
auto throwError (HRESULT result, const char *message) -> void
 Throws an exception after a COM error.
 
auto throwError (HRESULT result, const std::error_category &errorCategory, const std::string &message) -> void
 Throws an exception after a COM error.
 
auto throwError (HRESULT result, const std::error_category &errorCategory, const char *message) -> void
 Throws an exception after a COM error.
 

Detailed Description

Windows COM functionality.

This namespace contains functionality related to the Windows Component Object Model (COM) interface.

Function Documentation

◆ throwError() [1/4]

auto xentara::utils::windows::com::throwError ( HRESULT  result,
const char *  message 
) -> void

Throws an exception after a COM error.

This function should be called to throw an exception if a COM function returns an error. It will attempt to get a detailed error message by calling GetErrorInfo(), and throw an exception based on the returned error info. If no error info is available, it will throw an std::system_error using result as error code, and xentara::utils::windows::hresultErrorCategory() as error category.

This function should only be called if FAILED(result) is true (or for which SUCCEEDED(result) is false, which is the same thing).

Parameters
resultThe return value of the failed function
messageA message describing the error
Exceptions
ExceptionThis exception is thrown if extended error infomation was available
std::systemerror This exception is thrown if no extended error infomation was available

◆ throwError() [2/4]

auto xentara::utils::windows::com::throwError ( HRESULT  result,
const std::error_category errorCategory,
const char *  message 
) -> void

Throws an exception after a COM error.

This function should be called to throw an exception if a COM function returns an error. It will attempt to get a detailed error message by calling GetErrorInfo(), and throw an exception based on the returned error info. If no error info is available, it will throw an std::system_error using result as error code.

This function should only be called if FAILED(result) is true (or for which SUCCEEDED(result) is false, which is the same thing).

Parameters
resultThe return value of the failed function
errorCategoryThe error category to use if an std::system_error is thrown. This should either be xentara::utils::windows::hresultErrorcategory(), or a COM subsystem specific error category, like xentara::utils::windows::wmi::errorCategory().
messageA message describing the error
Exceptions
ExceptionThis exception is thrown if extended error infomation was available
std::systemerror This exception is thrown if no extended error infomation was available

◆ throwError() [3/4]

auto xentara::utils::windows::com::throwError ( HRESULT  result,
const std::error_category errorCategory,
const std::string message 
) -> void

Throws an exception after a COM error.

This function should be called to throw an exception if a COM function returns an error. It will attempt to get a detailed error message by calling GetErrorInfo(), and throw an exception based on the returned error info. If no error info is available, it will throw an std::system_error using result as error code.

This function should only be called if FAILED(result) is true (or for which SUCCEEDED(result) is false, which is the same thing).

Parameters
resultThe return value of the failed function.
errorCategoryThe error category to use if an std::system_error is thrown. This should either be xentara::utils::windows::hresultErrorcategory(), or a COM subsystem specific error category, like xentara::utils::windows::wmi::errorCategory().
messageA message describing the error
Exceptions
ExceptionThis exception is thrown if extended error infomation was available
std::systemerror This exception is thrown if no extended error infomation was available

◆ throwError() [4/4]

auto xentara::utils::windows::com::throwError ( HRESULT  result,
const std::string message 
) -> void

Throws an exception after a COM error.

This function should be called to throw an exception if a COM function returns an error. It will attempt to get a detailed error message by calling GetErrorInfo(), and throw an exception based on the returned error info. If no error info is available, it will throw an std::system_error using result as error code, and xentara::utils::windows::hresultErrorCategory() as error category.

This function should only be called if FAILED(result) is true (or for which SUCCEEDED(result) is false, which is the same thing).

Parameters
resultThe return value of the failed function.
messageA message describing the error
Exceptions
ExceptionThis exception is thrown if extended error infomation was available
std::systemerror This exception is thrown if no extended error infomation was available