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();
}
}
}
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();
}
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);
}
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);
}
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));
}
Aggregations