您的位置:首页 > 编程语言 > C语言/C++

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 );
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: