use of com.sun.jna.platform.win32.WinNT.HRESULT in project jna by java-native-access.
the class EnumMoniker_Test method Skip.
@Test
public void Skip() {
// GetRunningObjectTable
PointerByReference pprot = new PointerByReference();
HRESULT hr = Ole32.INSTANCE.GetRunningObjectTable(new DWORD(0), pprot);
COMUtils.checkRC(hr);
IRunningObjectTable rot = new RunningObjectTable(pprot.getValue());
// EnumRunning
PointerByReference ppenumMoniker = new PointerByReference();
hr = rot.EnumRunning(ppenumMoniker);
COMUtils.checkRC(hr);
IEnumMoniker iterator = new EnumMoniker(ppenumMoniker.getValue());
// Reset
hr = iterator.Reset();
COMUtils.checkRC(hr);
// Next
PointerByReference rgelt1 = new PointerByReference();
ULONGByReference pceltFetched1 = new ULONGByReference();
hr = iterator.Next(new ULONG(1), rgelt1, pceltFetched1);
COMUtils.checkRC(hr);
// Reset
hr = iterator.Reset();
COMUtils.checkRC(hr);
// Skip
hr = iterator.Skip(new ULONG(1));
COMUtils.checkRC(hr);
// Next
PointerByReference rgelt2 = new PointerByReference();
ULONGByReference pceltFetched2 = new ULONGByReference();
hr = iterator.Next(new ULONG(1), rgelt2, pceltFetched2);
COMUtils.checkRC(hr);
assertNotEquals(rgelt1.getValue(), rgelt2.getValue());
}
use of com.sun.jna.platform.win32.WinNT.HRESULT in project jna by java-native-access.
the class IDispatchTest method createIDispatch.
private Dispatch createIDispatch() {
try {
PointerByReference pDispatch = new PointerByReference();
// Get CLSID for Shell.Application...
CLSID.ByReference clsid = new CLSID.ByReference();
HRESULT hr = Ole32.INSTANCE.CLSIDFromProgID("Shell.Application", clsid);
if (W32Errors.FAILED(hr)) {
Ole32.INSTANCE.CoUninitialize();
COMUtils.checkRC(hr);
}
hr = Ole32.INSTANCE.CoCreateInstance(clsid, null, WTypes.CLSCTX_SERVER, IDispatch.IID_IDISPATCH, pDispatch);
if (W32Errors.FAILED(hr)) {
COMUtils.checkRC(hr);
}
return new Dispatch(pDispatch.getValue());
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of com.sun.jna.platform.win32.WinNT.HRESULT in project jna by java-native-access.
the class IDispatchTest method testGetIDsOfNames.
public void testGetIDsOfNames() {
Dispatch dispatch = this.createIDispatch();
WString[] ptName = new WString[] { new WString("Application") };
DISPIDByReference pdispID = new DISPIDByReference();
HRESULT hr = dispatch.GetIDsOfNames(new REFIID(Guid.IID_NULL), ptName, 1, LOCALE_SYSTEM_DEFAULT, pdispID);
COMUtils.checkRC(hr);
assertEquals(0, hr.intValue());
}
use of com.sun.jna.platform.win32.WinNT.HRESULT in project jna by java-native-access.
the class ITypeInfoTest method testGetDocumentation.
@Test
public void testGetDocumentation() {
ITypeInfo[] typeInfos = getTypeInfos();
MEMBERID memid = new MEMBERID(0);
BSTRByReference pBstrName = new BSTRByReference();
BSTRByReference pBstrDocString = new BSTRByReference();
DWORDByReference pdwHelpContext = new DWORDByReference();
BSTRByReference pBstrHelpFile = new BSTRByReference();
for (ITypeInfo typeInfo : typeInfos) {
HRESULT hr = typeInfo.GetDocumentation(memid, pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile);
if (COMUtils.SUCCEEDED(hr)) {
//System.out.println("pBstrHelpFile: " + pBstrHelpFile.getValue());
return;
}
}
throw new RuntimeException("Didn't find documentation in any of the type infos");
}
use of com.sun.jna.platform.win32.WinNT.HRESULT in project jna by java-native-access.
the class RunningObjectTable_Test method GetTimeOfLastChange.
@Test
public void GetTimeOfLastChange() {
PointerByReference pprot = new PointerByReference();
HRESULT hr = Ole32.INSTANCE.GetRunningObjectTable(new DWORD(0), pprot);
COMUtils.checkRC(hr);
IRunningObjectTable rot = new RunningObjectTable(pprot.getValue());
//Can't yet be tested as IMoniker is not fully implemented,
// so we can't register an object, and hence can't get a registration key
//rot.GetTimeOfLastChange(pmkObjectName, pfiletime);
}
Aggregations