Package org.metricshub.wmi.wbem
Class WmiComHelper
java.lang.Object
org.metricshub.wmi.wbem.WmiComHelper
Class with various static methods to help with COM interaction.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object
comInvokerInvokeNativeObject
(com.sun.jna.Pointer contextPointer, int vtableId, Object[] args, Class<?> returnType) Same function than in com.sun.jna.platform.win32.COM.COMInvoker.static void
Initializes COM library and sets security to impersonate the local userName.static boolean
static void
UnInitialize the COM library.
-
Method Details
-
initializeComLibrary
Initializes COM library and sets security to impersonate the local userName. This function needs to be called at least once for each thread, as COM must be initialized for each thread. You can call this function even if COM has already been initialized. It will verify first whether COM initialization has already been done for this thread before proceeding. The threading model is multi-threaded.- Throws:
WmiComException
- when COM library cannot be instantiatedIllegalStateException
- when COM library has already been initialized with a different threading model
-
unInitializeCom
public static void unInitializeCom()UnInitialize the COM library. -
isComInitialized
public static boolean isComInitialized()- Returns:
- whether COM has been initialized for the current thread
-
comInvokerInvokeNativeObject
public static Object comInvokerInvokeNativeObject(com.sun.jna.Pointer contextPointer, int vtableId, Object[] args, Class<?> returnType) Same function than in com.sun.jna.platform.win32.COM.COMInvoker._invokeNativeInt- Parameters:
contextPointer
-vtableId
-args
-returnType
-- Returns:
- whatever the specified function returns
-