Search in sources :

Example 1 with User32

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

the class Shell32Test method testShellExecuteEx.

public void testShellExecuteEx() {
    File file = new File(System.getProperty("java.io.tmpdir"), System.nanoTime() + ".txt");
    try {
        try {
            fillTempFile(file);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        SHELLEXECUTEINFO lpExecInfo = new SHELLEXECUTEINFO();
        // to avoid opening something and having hProcess come up null
        // (meaning we opened something but can't close it)
        // we will do a negative test with a bogus action.
        lpExecInfo.lpVerb = "0p3n";
        lpExecInfo.nShow = User32.SW_SHOWDEFAULT;
        lpExecInfo.fMask = Shell32.SEE_MASK_NOCLOSEPROCESS | Shell32.SEE_MASK_FLAG_NO_UI;
        lpExecInfo.lpFile = file.getAbsolutePath();
        assertFalse("ShellExecuteEx should have returned false - action verb was bogus.", Shell32.INSTANCE.ShellExecuteEx(lpExecInfo));
        assertEquals("GetLastError() should have been set to ERROR_NO_ASSOCIATION because of bogus action", W32Errors.ERROR_NO_ASSOCIATION, Native.getLastError());
    } finally {
        if (file.exists()) {
            file.delete();
        }
    }
}
Also used : SHELLEXECUTEINFO(com.sun.jna.platform.win32.ShellAPI.SHELLEXECUTEINFO) IOException(java.io.IOException) File(java.io.File)

Example 2 with User32

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

the class Shell32Test method testResizeDesktopFromBottom.

public void testResizeDesktopFromBottom() throws InterruptedException {
    newAppBar();
    APPBARDATA data = new APPBARDATA.ByReference();
    data.uEdge.setValue(ShellAPI.ABE_BOTTOM);
    data.rc.top = User32.INSTANCE.GetSystemMetrics(User32.SM_CYFULLSCREEN) - RESIZE_DELTA;
    data.rc.left = 0;
    data.rc.bottom = User32.INSTANCE.GetSystemMetrics(User32.SM_CYFULLSCREEN);
    data.rc.right = User32.INSTANCE.GetSystemMetrics(User32.SM_CXFULLSCREEN);
    queryPos(data);
    UINT_PTR h = Shell32.INSTANCE.SHAppBarMessage(new DWORD(ShellAPI.ABM_SETPOS), data);
    assertNotNull(h);
    assertTrue(h.intValue() >= 0);
    removeAppBar();
}
Also used : DWORD(com.sun.jna.platform.win32.WinDef.DWORD) UINT_PTR(com.sun.jna.platform.win32.WinDef.UINT_PTR) APPBARDATA(com.sun.jna.platform.win32.ShellAPI.APPBARDATA) PointerByReference(com.sun.jna.ptr.PointerByReference)

Example 3 with User32

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

the class User32Test method testGetDesktopWindow.

@Test
public void testGetDesktopWindow() {
    HWND desktopWindow = User32.INSTANCE.GetDesktopWindow();
    assertNotNull("Failed to get desktop window HWND", desktopWindow);
}
Also used : HWND(com.sun.jna.platform.win32.WinDef.HWND) Test(org.junit.Test)

Example 4 with User32

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

the class User32Test method testGetLastInputInfo.

@Test
public void testGetLastInputInfo() throws Exception {
    LASTINPUTINFO plii = new LASTINPUTINFO();
    assertEquals(plii.size(), plii.cbSize);
    assertTrue(User32.INSTANCE.GetLastInputInfo(plii));
    assertTrue(Kernel32.INSTANCE.GetTickCount() >= plii.dwTime);
    assertTrue(plii.dwTime > 0);
}
Also used : LASTINPUTINFO(com.sun.jna.platform.win32.WinUser.LASTINPUTINFO) Test(org.junit.Test)

Example 5 with User32

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

the class User32Test method testMonitorFromRect.

@Test
public final void testMonitorFromRect() {
    int dwFlags = WinUser.MONITOR_DEFAULTTOPRIMARY;
    RECT lprc = new RECT();
    assertNotNull(User32.INSTANCE.MonitorFromRect(lprc, dwFlags));
}
Also used : RECT(com.sun.jna.platform.win32.WinDef.RECT) Test(org.junit.Test)

Aggregations

HWND (com.sun.jna.platform.win32.WinDef.HWND)23 Test (org.junit.Test)21 HDC (com.sun.jna.platform.win32.WinDef.HDC)10 LPARAM (com.sun.jna.platform.win32.WinDef.LPARAM)8 HANDLE (com.sun.jna.platform.win32.WinNT.HANDLE)8 Pointer (com.sun.jna.Pointer)7 LRESULT (com.sun.jna.platform.win32.WinDef.LRESULT)7 WPARAM (com.sun.jna.platform.win32.WinDef.WPARAM)7 RECT (com.sun.jna.platform.win32.WinDef.RECT)6 PIXELFORMATDESCRIPTOR (com.sun.jna.platform.win32.WinGDI.PIXELFORMATDESCRIPTOR)6 BufferedImage (java.awt.image.BufferedImage)5 DWORDByReference (com.sun.jna.platform.win32.WinDef.DWORDByReference)4 HICON (com.sun.jna.platform.win32.WinDef.HICON)4 POINT (com.sun.jna.platform.win32.WinDef.POINT)4 PointerByReference (com.sun.jna.ptr.PointerByReference)4 File (java.io.File)4 Memory (com.sun.jna.Memory)3 DesktopWindow (com.sun.jna.platform.DesktopWindow)3 DWORD (com.sun.jna.platform.win32.WinDef.DWORD)3 HBITMAP (com.sun.jna.platform.win32.WinDef.HBITMAP)3