mirror of https://github.com/tongzx/nt5src
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
901 B
51 lines
901 B
/*++
|
|
|
|
Copyright (C) 1997-2001 Microsoft Corporation
|
|
|
|
Module Name:
|
|
|
|
Abstract:
|
|
|
|
History:
|
|
|
|
--*/
|
|
|
|
#include "precomp.h"
|
|
#include "utils.h"
|
|
|
|
|
|
DWORD WaitOnProcess(char *szExe, char *szParams, bool bHidden/*=true*/, bool bWait/*=true*/)
|
|
{
|
|
STARTUPINFO si;
|
|
PROCESS_INFORMATION pi;
|
|
BOOL bRet;
|
|
DWORD dwExitCode=STILL_ACTIVE;
|
|
|
|
|
|
ZeroMemory(&si,sizeof(si));
|
|
si.cb=sizeof(si);
|
|
|
|
bRet=CreateProcess(szExe,szParams,NULL,NULL,NULL,
|
|
((bHidden)?DETACHED_PROCESS:CREATE_NEW_CONSOLE),NULL,NULL,&si,&pi);
|
|
|
|
//wait until done
|
|
//===============
|
|
|
|
if (bRet && bWait)
|
|
{
|
|
while(dwExitCode==STILL_ACTIVE)
|
|
{
|
|
Sleep(100); //don't be a pig
|
|
GetExitCodeProcess(pi.hProcess,&dwExitCode);
|
|
}
|
|
|
|
CloseHandle(pi.hThread);
|
|
CloseHandle(pi.hProcess);
|
|
}
|
|
else
|
|
{
|
|
dwExitCode=(bRet)?0:1;
|
|
}
|
|
|
|
return dwExitCode;
|
|
}
|