我试图弄清楚如何从我用CreateProcessW创建的过程中读取标准输出/错误.我查看了文档,谷歌搜索并搜索了这个列表,但我找不到好的指针/样本:)
这是我到目前为止所提出的(它在Windows上运行正常,它是我的java代码中的相关代码段):
Kernel32 kernel32 = (Kernel32) Native.loadLibrary("kernel32", Kernel32.class);
Kernel32.StartupInfo startupInfo = new Kernel32.StartupInfo();
Kernel32.ProcessInfo processInformation = new Kernel32.ProcessInfo();
if (!kernel32.CreateProcessW(null, new WString(command), null, null, false,
DETACHED_PROCESS, null, new WString(dir.getAbsolutePath()), startupInfo,
processInformation)) {
throw new IOException("Could not start process. Errno: " +
kernel32.GetLastError());
}
kernel32.CloseHandle(processInformation.hProcess);
kernel32.CloseHandle(processInformation.hThread);
Run Code Online (Sandbox Code Playgroud)
那么......我如何从该过程中获取输出?任何人都已经这样做并且关心分享样品吗?
谢谢你们提前帮助.