我想在C程序中执行TEST.exe.我用的时候
system( "TEST.exe <input-file> output-file" );
Run Code Online (Sandbox Code Playgroud)
我可以得到我的预期.
但是当我使用以下代码时,CreateProcessW()无法正常工作(请参阅如何运行外部程序?):
if (CreateProcessW(const_cast<LPCWSTR>(FullPathToExe.c_str()),
pwszParam, 0, 0, false,
CREATE_DEFAULT_ERROR_MODE, 0, 0,
&siStartupInfo, &piProcessInfo) != false)
{
/* Watch the process. */
dwExitCode = WaitForSingleObject(piProcessInfo.hProcess, (SecondsToWait * 1000));
iReturnVal = GetLastError();
}
else
{
/* CreateProcess failed */
iReturnVal = GetLastError();
}
Run Code Online (Sandbox Code Playgroud)
哪里
FullPathToExe="TEST.exe", pwszParam="TEST.exe <input-file> output-file".
Run Code Online (Sandbox Code Playgroud)
WaitForSingleObject()返回258,GetLastError()返回1813("在图像文件中找不到指定的资源类型.").
此外,上面的CreateProcessW()代码运行我自己的HelloProcess.exe(打印问候,睡眠时间由以下数字确定,然后退出.)
FullPathToExe="HelloProcess.exe", pwszParam="HelloProcess.exe 10".
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?谢谢你的任何提示!