1
如何通过Java中的某个ProcessId获取进程对象。通过进程Id获取进程对象
我使用JNA来创建一个进程,因为我想在后台打开一个应用程序。
WinBase.STARTUPINFO startupInfo = new WinBase.STARTUPINFO();
startupInfo.dwFlags = 1;
WinBase.PROCESS_INFORMATION.ByReference processInformation = new WinBase.PROCESS_INFORMATION.ByReference();
Kernel32.INSTANCE.CreateProcess(null, "C:\\Program Files\\...", null, null, true, new WinDef.DWORD(0), Pointer.NULL, System.getProperty("java.io.tmpdir"), startupInfo, processInformation);
int prozessId = processInformation.dwProcessId.intValue();
你为什么不使用Process?你如何*不*在Java的背景下打开一个进程? –
我试过这个,但是我的应用程序总是在前台开始。我为此使用ProcessBuilder – Higune
我想这个问题是关于Windows API编程而不是Java! –