C++ 调用exe,可等待调用的exe执行完毕后才继续执行父进程 CreateProcess
2012-01-02 21:49
721 查看
#include <windows.h>
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
// Start the child process.
if( !CreateProcess( _T("D:\\progX\\UseCSharp\\Debug\\Ply2Depth.exe"),
_T(" 1 1 0 0 D:\\progX\\laurana50k-depth1_UV128_12_1frame.yuv D:\\progX\\laurana50k-depth2_UV128_12_1frame.yuv"), // Command line. There should be a space at the beginning
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi ) // Pointer to PROCESS_INFORMATION structure.
)
{
printf( "CreateProcess failed (%d)./n", GetLastError() );
return 0;
}
// Wait until child process exits.
WaitForSingleObject( pi.hProcess, INFINITE );
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
// Start the child process.
if( !CreateProcess( _T("D:\\progX\\UseCSharp\\Debug\\Ply2Depth.exe"),
_T(" 1 1 0 0 D:\\progX\\laurana50k-depth1_UV128_12_1frame.yuv D:\\progX\\laurana50k-depth2_UV128_12_1frame.yuv"), // Command line. There should be a space at the beginning
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi ) // Pointer to PROCESS_INFORMATION structure.
)
{
printf( "CreateProcess failed (%d)./n", GetLastError() );
return 0;
}
// Wait until child process exits.
WaitForSingleObject( pi.hProcess, INFINITE );
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
相关文章推荐
- delphi调用外部EXE,等待执行完毕时再响应后续操作.
- winform c#调用外部EXE程序,并等待外部EXE程序执行完毕才执行下面的代码的方法。
- vc调用EXE文件,并且等待其执行完毕.
- c++执行cmd指令、cmd隐藏进程不出现控制台、结束进程、调用exe、CreateProcess以及WinExec的使用
- delphi调用外部EXE,等待执行完毕时再响应后续操作.
- java.lang.Runtime.getRuntime().exec 调用后,等待被调用程序结束后再继续执行
- C/C++执行外部程序(调用外部exe程序)
- (转)c++--C++中调用exe可执行文件
- c++ win32调用exe,并等待其结束
- C#winform调用外部程序,等待外部程序执行完毕才执行下面代码
- C++执行外部程序(调用外部exe程序)
- C/C++ ShellExecuteEx调用exe可执行文件
- C++调用exe可执行文件
- C/C++ ShellExecuteEx调用exe可执行文件
- Windows批处理 调用程序后 不等待子进程 父进程继续执行命令
- js for中调用ajax 。等待ajax执行完再继续循环
- c++本程序如何调用执行另一个程序WinExce,ShellExecute,CreateProcess
- C++中调用exe可执行文件
- Windows批处理 调用程序后 不等待子进程 父进程继续执行命令
- C++启动可执行文件(.exe)的方法CreateProcess