diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Wbemcli.java b/contrib/platform/src/com/sun/jna/platform/win32/Wbemcli.java index 9f3448a744..2ee1d8e06b 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Wbemcli.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Wbemcli.java @@ -28,7 +28,6 @@ import com.sun.jna.platform.win32.Guid.CLSID; import com.sun.jna.platform.win32.Guid.GUID; import com.sun.jna.platform.win32.Variant.VARIANT; -import com.sun.jna.platform.win32.WTypes; import com.sun.jna.platform.win32.WTypes.BSTR; import com.sun.jna.platform.win32.WinNT.HRESULT; import com.sun.jna.platform.win32.COM.COMUtils; @@ -37,7 +36,9 @@ import com.sun.jna.ptr.PointerByReference; /** - * This header is used by Remote Desktop Services. + * This header is used by Remote Desktop Services. It contains programming + * interfaces for enumerating and querying Common Information Model (CIM) + * objects. */ public interface Wbemcli { @@ -109,7 +110,6 @@ public static IWbemLocator create() { HRESULT hres = Ole32.INSTANCE.CoCreateInstance(CLSID_WbemLocator, null, WTypes.CLSCTX_INPROC_SERVER, IID_IWbemLocator, pbr); if (COMUtils.FAILED(hres)) { - Ole32.INSTANCE.CoUninitialize(); throw new WbemcliException("Failed to create WbemLocator object.", hres.intValue()); } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WbemcliUtil.java b/contrib/platform/src/com/sun/jna/platform/win32/WbemcliUtil.java index 9d7ec951e0..aa456cd016 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WbemcliUtil.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WbemcliUtil.java @@ -58,13 +58,6 @@ public class WbemcliUtil { */ public static final String DEFAULT_NAMESPACE = "ROOT\\CIMV2"; - // Constant for WMI used often. - private static final BSTR WQL = OleAuto.INSTANCE.SysAllocString("WQL"); - - // Track initialization of COM and Security - private static boolean comInitialized = false; - private static boolean securityInitialized = false; - /** * Enum containing the property used for WMI Namespace query. */ @@ -352,19 +345,6 @@ public void incrementResultCount() { } } - /** - * Private construtor for cleanup hook - */ - private WbemcliUtil() { - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - OleAuto.INSTANCE.SysFreeString(WQL); - } - }); - } - - /** * Create a WMI Query * @@ -565,9 +545,11 @@ public static > IEnumWbemClassObject selectProperties(IWbemSer // Send the query. The flags allow us to return immediately and begin // enumerating in the forward direction as results come in. BSTR queryStr = OleAuto.INSTANCE.SysAllocString(sb.toString().replaceAll("\\\\", "\\\\\\\\")); - HRESULT hres = svc.ExecQuery(WQL, queryStr, + BSTR wql = OleAuto.INSTANCE.SysAllocString("WQL"); + HRESULT hres = svc.ExecQuery(wql, queryStr, Wbemcli.WBEM_FLAG_FORWARD_ONLY | Wbemcli.WBEM_FLAG_RETURN_IMMEDIATELY, null, pEnumerator); OleAuto.INSTANCE.SysFreeString(queryStr); + OleAuto.INSTANCE.SysFreeString(wql); if (COMUtils.FAILED(hres)) { svc.Release(); throw new WbemcliException(String.format("Query '%s' failed.", sb.toString()), hres.intValue());