Search in sources :

Example 91 with HRESULT

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");
}
Also used : HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) MEMBERID(com.sun.jna.platform.win32.OaIdl.MEMBERID) BSTRByReference(com.sun.jna.platform.win32.WTypes.BSTRByReference) DWORDByReference(com.sun.jna.platform.win32.WinDef.DWORDByReference) WORDByReference(com.sun.jna.platform.win32.WinDef.WORDByReference) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 92 with HRESULT

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));
}
Also used : HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) PointerByReference(com.sun.jna.ptr.PointerByReference) GUID(com.sun.jna.platform.win32.Guid.GUID)

Example 93 with HRESULT

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;
}
Also used : HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) CLSID(com.sun.jna.platform.win32.Guid.CLSID) PointerByReference(com.sun.jna.ptr.PointerByReference) PointerByReference(com.sun.jna.ptr.PointerByReference)

Example 94 with HRESULT

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);
}
Also used : HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) PointerByReference(com.sun.jna.ptr.PointerByReference) DWORD(com.sun.jna.platform.win32.WinDef.DWORD) Test(org.junit.Test)

Example 95 with HRESULT

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);
    }
}
Also used : ULONG(com.sun.jna.platform.win32.WinDef.ULONG) HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) DWORD(com.sun.jna.platform.win32.WinDef.DWORD) REFIID(com.sun.jna.platform.win32.Guid.REFIID) ULONGByReference(com.sun.jna.platform.win32.WinDef.ULONGByReference) PointerByReference(com.sun.jna.ptr.PointerByReference) Test(org.junit.Test)

Aggregations

HRESULT (com.sun.jna.platform.win32.WinNT.HRESULT)102 PointerByReference (com.sun.jna.ptr.PointerByReference)57 Test (org.junit.Test)26 REFIID (com.sun.jna.platform.win32.Guid.REFIID)20 UINT (com.sun.jna.platform.win32.WinDef.UINT)15 WString (com.sun.jna.WString)12 DWORD (com.sun.jna.platform.win32.WinDef.DWORD)12 WinNT (com.sun.jna.platform.win32.WinNT)12 DWORDByReference (com.sun.jna.platform.win32.WinDef.DWORDByReference)11 VARIANT (com.sun.jna.platform.win32.Variant.VARIANT)10 MEMBERID (com.sun.jna.platform.win32.OaIdl.MEMBERID)9 BSTRByReference (com.sun.jna.platform.win32.WTypes.BSTRByReference)9 ULONG (com.sun.jna.platform.win32.WinDef.ULONG)9 IID (com.sun.jna.platform.win32.Guid.IID)8 DISPIDByReference (com.sun.jna.platform.win32.OaIdl.DISPIDByReference)8 IntByReference (com.sun.jna.ptr.IntByReference)8 UINTByReference (com.sun.jna.platform.win32.WinDef.UINTByReference)7 COMException (com.sun.jna.platform.win32.COM.COMException)6 ConnectionPoint (com.sun.jna.platform.win32.COM.ConnectionPoint)6 Pointer (com.sun.jna.Pointer)5