Search in sources :

Example 1 with IEnumMoniker

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

Example 2 with IEnumMoniker

use of com.sun.jna.platform.win32.COM.IEnumMoniker in project jna by java-native-access.

the class EnumMoniker_Test method Clone.

@Test
public void Clone() {
    // 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 iterator1 = new EnumMoniker(ppenumMoniker.getValue());
    // iterator1.Reset
    hr = iterator1.Reset();
    COMUtils.checkRC(hr);
    // iterator1.Next
    PointerByReference rgelt1 = new PointerByReference();
    ULONGByReference pceltFetched1 = new ULONGByReference();
    hr = iterator1.Next(new ULONG(1), rgelt1, pceltFetched1);
    COMUtils.checkRC(hr);
    // iterator1.Clone
    PointerByReference ppenum = new PointerByReference();
    hr = iterator1.Clone(ppenum);
    COMUtils.checkRC(hr);
    IEnumMoniker iterator2 = new EnumMoniker(ppenum.getValue());
    // iterator2.Next
    PointerByReference rgelt2 = new PointerByReference();
    ULONGByReference pceltFetched2 = new ULONGByReference();
    hr = iterator2.Next(new ULONG(1), rgelt2, pceltFetched2);
    COMUtils.checkRC(hr);
    assertNotEquals(rgelt1.getValue(), rgelt2.getValue());
    // iterator1.Next
    rgelt1 = new PointerByReference();
    pceltFetched1 = new ULONGByReference();
    hr = iterator1.Next(new ULONG(1), rgelt1, pceltFetched1);
    COMUtils.checkRC(hr);
    assertEquals(rgelt1.getValue(), rgelt2.getValue());
}
Also used : ULONG(com.sun.jna.platform.win32.WinDef.ULONG) HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) PointerByReference(com.sun.jna.ptr.PointerByReference) DWORD(com.sun.jna.platform.win32.WinDef.DWORD) ULONGByReference(com.sun.jna.platform.win32.WinDef.ULONGByReference) Test(org.junit.Test)

Example 3 with IEnumMoniker

use of com.sun.jna.platform.win32.COM.IEnumMoniker in project jna by java-native-access.

the class EnumMoniker_Test method Next.

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

Example 4 with IEnumMoniker

use of com.sun.jna.platform.win32.COM.IEnumMoniker in project jna by java-native-access.

the class EnumMoniker_Test method Reset.

@Test
public void Reset() {
    // 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);
    // Next
    PointerByReference rgelt2 = new PointerByReference();
    ULONGByReference pceltFetched2 = new ULONGByReference();
    hr = iterator.Next(new ULONG(1), rgelt2, pceltFetched2);
    COMUtils.checkRC(hr);
    assertEquals(rgelt1.getValue(), rgelt2.getValue());
}
Also used : ULONG(com.sun.jna.platform.win32.WinDef.ULONG) HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) PointerByReference(com.sun.jna.ptr.PointerByReference) DWORD(com.sun.jna.platform.win32.WinDef.DWORD) ULONGByReference(com.sun.jna.platform.win32.WinDef.ULONGByReference) Test(org.junit.Test)

Example 5 with IEnumMoniker

use of com.sun.jna.platform.win32.COM.IEnumMoniker 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

DWORD (com.sun.jna.platform.win32.WinDef.DWORD)5 ULONG (com.sun.jna.platform.win32.WinDef.ULONG)5 ULONGByReference (com.sun.jna.platform.win32.WinDef.ULONGByReference)5 HRESULT (com.sun.jna.platform.win32.WinNT.HRESULT)5 PointerByReference (com.sun.jna.ptr.PointerByReference)5 Test (org.junit.Test)5 REFIID (com.sun.jna.platform.win32.Guid.REFIID)1