use of com.sun.jna.platform.win32.WinNT.HRESULT in project jna by java-native-access.
the class ITypeInfoTest method testGetDllEntry.
@Test
@Ignore("Needs a DLL that contains code")
public void testGetDllEntry() {
ITypeInfo[] typeInfos = getTypeInfos();
MEMBERID memid = new MEMBERID(0);
BSTRByReference pBstrDllName = new BSTRByReference();
BSTRByReference pBstrName = new BSTRByReference();
WORDByReference pwOrdinal = new WORDByReference();
for (ITypeInfo typeInfo : typeInfos) {
HRESULT hr = typeInfo.GetDllEntry(memid, INVOKEKIND.INVOKE_FUNC, pBstrDllName, pBstrName, pwOrdinal);
if (COMUtils.SUCCEEDED(hr)) {
//System.out.println("pwOrdinal: " + pwOrdinal.getValue());
return;
}
}
throw new RuntimeException("Didn't find Dll entry for member in any of the type infos");
}
use of com.sun.jna.platform.win32.WinNT.HRESULT in project jna by java-native-access.
the class ITypeLibTest method testGetTypeInfoOfGuid.
public void testGetTypeInfoOfGuid() {
ITypeLib shellTypeLib = loadShellTypeLib();
// GUID for dispinterface IFolderViewOC
GUID iFolderViewOC = new GUID("{9BA05970-F6A8-11CF-A442-00A0C90A8F39}");
PointerByReference pbr = new PointerByReference();
HRESULT hr = shellTypeLib.GetTypeInfoOfGuid(iFolderViewOC, pbr);
assertTrue(COMUtils.SUCCEEDED(hr));
}
use of com.sun.jna.platform.win32.WinNT.HRESULT in project jna by java-native-access.
the class IUnknownTest method createIUnknown.
private Unknown createIUnknown() {
try {
PointerByReference pUnknown = new PointerByReference();
// Get CLSID for Word.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, IUnknown.IID_IUNKNOWN, pUnknown);
if (W32Errors.FAILED(hr)) {
COMUtils.checkRC(hr);
}
return new Unknown(pUnknown.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 RunningObjectTable_Test method NoteChangeTime.
@Test
public void NoteChangeTime() {
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.NoteChangeTime(dwRegister, pfiletime);
}
use of com.sun.jna.platform.win32.WinNT.HRESULT in project jna by java-native-access.
the class RunningObjectTable_Test method GetObject.
@Test
public void GetObject() {
PointerByReference pprot = new PointerByReference();
HRESULT hr = Ole32.INSTANCE.GetRunningObjectTable(new DWORD(0), pprot);
COMUtils.checkRC(hr);
IRunningObjectTable rot = new RunningObjectTable(pprot.getValue());
PointerByReference ppenumMoniker = new PointerByReference();
hr = rot.EnumRunning(ppenumMoniker);
COMUtils.checkRC(hr);
IEnumMoniker iterator = new EnumMoniker(ppenumMoniker.getValue());
iterator.Reset();
PointerByReference rgelt = new PointerByReference();
ULONGByReference pceltFetched = new ULONGByReference();
hr = iterator.Next(new ULONG(1), rgelt, pceltFetched);
while (WinNT.S_OK.equals(hr) && pceltFetched.getValue().intValue() > 0) {
Moniker moniker = new Moniker(rgelt.getValue());
PointerByReference ppbc = new PointerByReference();
Ole32.INSTANCE.CreateBindCtx(new DWORD(), ppbc);
String name = moniker.GetDisplayName(ppbc.getValue(), moniker.getPointer());
PointerByReference ppunkObject = new PointerByReference();
hr = rot.GetObject(moniker.getPointer(), ppunkObject);
COMUtils.checkRC(hr);
IUnknown unk = new Unknown(ppunkObject.getValue());
PointerByReference ppvObject = new PointerByReference();
hr = unk.QueryInterface(new REFIID(IUnknown.IID_IUNKNOWN), ppvObject);
assertEquals(0, hr.intValue());
assertNotNull(ppvObject.getValue());
moniker.Release();
hr = iterator.Next(new ULONG(1), rgelt, pceltFetched);
}
}
Aggregations