运行进程且得到进程的退出码

	DWORD liExitCode = -1;
	CString lstrExePath = _T("运行路径");

	SHELLEXECUTEINFO shellexecuteinfo;
	ZeroMemory(&shellexecuteinfo,sizeof(shellexecuteinfo));
	shellexecuteinfo.cbSize = sizeof(shellexecuteinfo);
	shellexecuteinfo.fMask = SEE_MASK_DEFAULT | SEE_MASK_NOCLOSEPROCESS;
	shellexecuteinfo.lpVerb = _T("open");
	shellexecuteinfo.lpFile = lstrExePath.GetBuffer(0);
	shellexecuteinfo.nShow = SW_HIDE;
	shellexecuteinfo.lpParameters = lstrExePath.GetBuffer(0);  

	BOOL bContinue = ShellExecuteEx(&shellexecuteinfo);
	if (bContinue != FALSE)
	{
		if (shellexecuteinfo.hProcess != NULL)
		{
			WaitForSingleObject(shellexecuteinfo.hProcess,INFINITE);

			BOOL lb = GetExitCodeProcess(shellexecuteinfo.hProcess,&liExitCode);//liExitCode就是进程的退出码

		}
	}



 
  
 
 

你可能感兴趣的:(C/C++)