if (W32Errors.SUCCEEDED(hr.intValue()))
Ole32.INSTANCE.CoUninitialize();
}
public void testCoCreateInstance() {
HRESULT hrCI = Ole32.INSTANCE.CoInitializeEx(null, 0);
GUID guid = Ole32Util
.getGUIDFromString("{00021401-0000-0000-C000-000000000046}"); // Shell object
GUID riid = Ole32Util
.getGUIDFromString("{000214EE-0000-0000-C000-000000000046}"); // IShellLinkA
PointerByReference pDispatch = new PointerByReference();
HRESULT hr = Ole32.INSTANCE.CoCreateInstance(guid, null, // pOuter =
// null, no
// aggregation
WTypes.CLSCTX_LOCAL_SERVER, riid, pDispatch);
assertTrue(W32Errors.SUCCEEDED(hr.intValue()));
assertTrue(!pDispatch.equals(Pointer.NULL));
// We leak this iUnknown reference because we don't have the JNACOM lib
// here to wrap the native iUnknown pointer and call iUnknown.release()
if (W32Errors.SUCCEEDED(hrCI.intValue()))
Ole32.INSTANCE.CoUninitialize();