xentara-utils v1.2.1
Xentara utilities 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.
 
auto begin (ResultSet resultSet) -> ResultSet
 Gets an end iterator for a result set.
 
auto end (ResultSet) -> std::default_sentinel_t
 Gets an end iterator for a result set.
 

Detailed Description

Windows WMI functionality.

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

Function Documentation

◆ begin()

auto xentara::utils::windows::wmi::begin ( ResultSet  resultSet) -> ResultSet

Gets an end iterator for a result set.

This function enables the use of ResultSet in range-based for loops

Parameters
resultSetThe result set to iterate over
Returns
Returns a copy of the result set, since the result is its own iterator

◆ end()

auto xentara::utils::windows::wmi::end ( ResultSet  ) -> std::default_sentinel_t

Gets an end iterator for a result set.

This function enables the use of ResultSet in range-based for loops

Returns
The global default sentinel

◆ 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.

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).

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).

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