use of com.sun.jna.platform.win32.WinBase.STARTUPINFO in project jna by java-native-access.
the class Advapi32Test method testCreateProcessWithLogonW.
public void testCreateProcessWithLogonW() {
String winDir = Kernel32Util.getEnvironmentVariable("WINDIR");
assertNotNull("No WINDIR value returned", winDir);
assertTrue("Specified WINDIR does not exist: " + winDir, new File(winDir).exists());
STARTUPINFO si = new STARTUPINFO();
si.lpDesktop = null;
PROCESS_INFORMATION results = new PROCESS_INFORMATION();
// i have the same combination on my luggage
boolean result = Advapi32.INSTANCE.CreateProcessWithLogonW("A" + System.currentTimeMillis(), "localhost", "12345", Advapi32.LOGON_WITH_PROFILE, new File(winDir, "notepad.exe").getAbsolutePath(), "", 0, null, "", si, results);
// we tried to run notepad as a bogus user, so it should fail.
assertFalse("CreateProcessWithLogonW should have returned false because the username was bogus.", result);
// should fail with "the user name or password is incorrect" (error 1326)
assertEquals("GetLastError() should have returned ERROR_LOGON_FAILURE because the username was bogus.", W32Errors.ERROR_LOGON_FAILURE, Native.getLastError());
}
use of com.sun.jna.platform.win32.WinBase.STARTUPINFO in project jna by java-native-access.
the class Kernel32Test method testCreateProcess.
public void testCreateProcess() {
WinBase.STARTUPINFO startupInfo = new WinBase.STARTUPINFO();
WinBase.PROCESS_INFORMATION.ByReference processInformation = new WinBase.PROCESS_INFORMATION.ByReference();
boolean status = Kernel32.INSTANCE.CreateProcess(null, "cmd.exe /c echo hi", null, null, true, new WinDef.DWORD(0), Pointer.NULL, System.getProperty("java.io.tmpdir"), startupInfo, processInformation);
assertTrue(status);
assertTrue(processInformation.dwProcessId.longValue() > 0);
}
Aggregations