xentara-utils v2.0.4
The Xentara Utility Library
Loading...
Searching...
No Matches
xentara::utils::windows::wmi Namespace Reference

Windows WMI functionality. More...

Classes

class  Locator
 A locator for WMI services. More...
 
class  Namespace
 A connection to a WMI namespace on the local machine. More...
 
class  Object
 A WMI object. More...
 
class  ResultSet
 A result set of a WMI query. More...
 

Functions

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

Detailed Description

Windows WMI functionality.

This namespace privides access to the Windows Management Intrumentation (WMI) system.

Function Documentation

◆ errorCategory()

auto xentara::utils::windows::wmi::errorCategory ( ) -> const std::error_category &

Returns an error category for WMI errors.

This error category can be used in conjuction with HRESULT return codes returned by methods of Windows Management Intrumentation (WMI) objects. It extends std::system_category by recognizing WMI subsystem specific error.

This category used the IWbemStatusCodeText interface to decode the result code.

The resurned error category can be passed to xentara::utils::windows::throwError() when a method of a WMI object has failed.

Include file
#include <xentara/utils/windows/wmi/Errors.hpp>
Returns
The category
See also
xentara::utils::windows::throwError()

◆ throwError() [1/2]

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

Throws an exception after a WMI error.

This function should be called to throw an exception if a WMI 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::wmi::errorCategory() 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).

Include file
#include <xentara/utils/windows/wmi/Errors.hpp>
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/2]

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

Throws an exception after a WMI error.

This function should be called to throw an exception if a WMI 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::wmi::errorCategory() 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).

Include file
#include <xentara/utils/windows/wmi/Errors.hpp>
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