Package oshi.util.platform.windows
Class WmiUtil
java.lang.Object
oshi.util.platform.windows.WmiUtil
Helper class for WMI
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The namespace where Open Hardware Monitor publishes to WMI,OHM_NAMESPACE="ROOT\\OpenHardwareMonitor"
. -
Method Summary
Modifier and TypeMethodDescriptiongetDateString
(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index) Gets a Date value from a WmiResult as a String in ISO 8601 formatstatic <T extends Enum<T>>
OffsetDateTimegetDateTime
(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index) Gets a DateTime value from a WmiResult as an OffsetDateTimestatic <T extends Enum<T>>
floatgetFloat
(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index) Gets a Float value from a WmiResultgetRefString
(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index) Gets a Reference value from a WmiResult as a Stringstatic <T extends Enum<T>>
intgetSint32
(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index) Gets a Sint32 value from a WmiResult.getString
(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index) Gets a String value from a WmiResultstatic <T extends Enum<T>>
intgetUint16
(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index) Gets a Uint16 value from a WmiResult.static <T extends Enum<T>>
intgetUint32
(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index) Gets an UINT32 value from a WmiResult.static <T extends Enum<T>>
longgetUint32asLong
(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index) Gets an UINT32 value from a WmiResult as a long, preserving the unsignedness.static <T extends Enum<T>>
longgetUint64
(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index) Gets a Uint64 value from a WmiResult (parsing the String).queryToString
(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiQuery<T> query) Translate a WmiQuery to the actual query string
-
Field Details
-
OHM_NAMESPACE
The namespace where Open Hardware Monitor publishes to WMI,OHM_NAMESPACE="ROOT\\OpenHardwareMonitor"
. This namespace is not built-in to WMI, so if OHM is not running would result in unnecessary log messages.- See Also:
-
-
Method Details
-
queryToString
public static <T extends Enum<T>> String queryToString(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiQuery<T> query) Translate a WmiQuery to the actual query string- Type Parameters:
T
- WMI queries use an Enum to identify the fields to query, and use the enum values as keys to retrieve the results.- Parameters:
query
- The WmiQuery object- Returns:
- The string that is queried in WMI
-
getString
public static <T extends Enum<T>> String getString(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index) Gets a String value from a WmiResult- Type Parameters:
T
- WMI queries use an Enum to identify the fields to query, and use the enum values as keys to retrieve the results.- Parameters:
result
- The WmiResult from which to fetch the valueproperty
- The property (column) to fetchindex
- The index (row) to fetch- Returns:
- The stored value if non-null, an empty-string otherwise
-
getDateString
public static <T extends Enum<T>> String getDateString(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index) Gets a Date value from a WmiResult as a String in ISO 8601 format- Type Parameters:
T
- WMI queries use an Enum to identify the fields to query, and use the enum values as keys to retrieve the results.- Parameters:
result
- The WmiResult from which to fetch the valueproperty
- The property (column) to fetchindex
- The index (row) to fetch- Returns:
- The stored value if non-null, an empty-string otherwise
-
getDateTime
public static <T extends Enum<T>> OffsetDateTime getDateTime(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index) Gets a DateTime value from a WmiResult as an OffsetDateTime- Type Parameters:
T
- WMI queries use an Enum to identify the fields to query, and use the enum values as keys to retrieve the results.- Parameters:
result
- The WmiResult from which to fetch the valueproperty
- The property (column) to fetchindex
- The index (row) to fetch- Returns:
- The stored value if non-null, otherwise the constant
Constants.UNIX_EPOCH
-
getRefString
public static <T extends Enum<T>> String getRefString(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index) Gets a Reference value from a WmiResult as a String- Type Parameters:
T
- WMI queries use an Enum to identify the fields to query, and use the enum values as keys to retrieve the results.- Parameters:
result
- The WmiResult from which to fetch the valueproperty
- The property (column) to fetchindex
- The index (row) to fetch- Returns:
- The stored value if non-null, an empty-string otherwise
-
getUint64
public static <T extends Enum<T>> long getUint64(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index) Gets a Uint64 value from a WmiResult (parsing the String). Note that while the CIM type is unsigned, the return type is signed and the parsing will exclude any return values above Long.MAX_VALUE.- Type Parameters:
T
- WMI queries use an Enum to identify the fields to query, and use the enum values as keys to retrieve the results.- Parameters:
result
- The WmiResult from which to fetch the valueproperty
- The property (column) to fetchindex
- The index (row) to fetch- Returns:
- The stored value if non-null and parseable as a long, 0 otherwise
-
getUint32
public static <T extends Enum<T>> int getUint32(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index) Gets an UINT32 value from a WmiResult. Note that while a UINT32 CIM type is unsigned, the return type is signed and requires further processing by the user if unsigned values are desired.- Type Parameters:
T
- WMI queries use an Enum to identify the fields to query, and use the enum values as keys to retrieve the results.- Parameters:
result
- The WmiResult from which to fetch the valueproperty
- The property (column) to fetchindex
- The index (row) to fetch- Returns:
- The stored value if non-null, 0 otherwise
-
getUint32asLong
public static <T extends Enum<T>> long getUint32asLong(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index) Gets an UINT32 value from a WmiResult as a long, preserving the unsignedness.- Type Parameters:
T
- WMI queries use an Enum to identify the fields to query, and use the enum values as keys to retrieve the results.- Parameters:
result
- The WmiResult from which to fetch the valueproperty
- The property (column) to fetchindex
- The index (row) to fetch- Returns:
- The stored value if non-null, 0 otherwise
-
getSint32
public static <T extends Enum<T>> int getSint32(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index) Gets a Sint32 value from a WmiResult. Note that while the CIM type is unsigned, the return type is signed and requires further processing by the user if unsigned values are desired.- Type Parameters:
T
- WMI queries use an Enum to identify the fields to query, and use the enum values as keys to retrieve the results.- Parameters:
result
- The WmiResult from which to fetch the valueproperty
- The property (column) to fetchindex
- The index (row) to fetch- Returns:
- The stored value if non-null, 0 otherwise
-
getUint16
public static <T extends Enum<T>> int getUint16(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index) Gets a Uint16 value from a WmiResult. Note that while the CIM type is unsigned, the return type is signed and requires further processing by the user if unsigned values are desired.- Type Parameters:
T
- WMI queries use an Enum to identify the fields to query, and use the enum values as keys to retrieve the results.- Parameters:
result
- The WmiResult from which to fetch the valueproperty
- The property (column) to fetchindex
- The index (row) to fetch- Returns:
- The stored value if non-null, 0 otherwise
-
getFloat
public static <T extends Enum<T>> float getFloat(com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult<T> result, T property, int index) Gets a Float value from a WmiResult- Type Parameters:
T
- WMI queries use an Enum to identify the fields to query, and use the enum values as keys to retrieve the results.- Parameters:
result
- The WmiResult from which to fetch the valueproperty
- The property (column) to fetchindex
- The index (row) to fetch- Returns:
- The stored value if non-null, 0 otherwise
-