Class WmiComHelper

java.lang.Object
org.metricshub.wmi.wbem.WmiComHelper

public class WmiComHelper extends Object
Class with various static methods to help with COM interaction.
  • Method Details

    • initializeComLibrary

      public static void initializeComLibrary() throws WmiComException
      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 instantiated
      IllegalStateException - 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