if (W32Errors.SUCCEEDED(hr.intValue()))
Ole32.INSTANCE.CoUninitialize();
}
public void testCoCreateInstance() {
HRESULT hrCI = Ole32.INSTANCE.CoInitializeEx(null, 0);
GUID guid = Ole32Util.getGUIDFromString("{13709620-C279-11CE-A49E-444553540000}"); //Shell object
GUID riid = Ole32Util.getGUIDFromString("{D8F015C0-C278-11CE-A49E-444553540000}"); //IShellDispatch
PointerByReference iUnknown = new PointerByReference();
HRESULT hr = Ole32.INSTANCE.CoCreateInstance(
guid,
null, // pOuter = null, no aggregation
ObjBase.CLSCTX_ALL,
riid,
iUnknown);
assertTrue(W32Errors.SUCCEEDED(hr.intValue()));
assertTrue(!iUnknown.getValue().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();