Hi,
I started one process using CreateProcess() in vc++. Now I want to set wait time out for that created process. Let consider, I am starting notepad using the above function, then I asked to handle that process. In this situation, the Notepad does not return any value. so this handling function still holds. I want to set the wait time, If the time exceed then that handled object should release, I have tried with WaitForSingleOb ject and set my time, the timeout function is encounted but the Handle resource doesnot release, here code snippet....
STARTUPINFO sInfo;
ZeroMemory(&sIn fo,sizeof(sInfo ));
PROCESS_INFORMA TION pInfo;
ZeroMemory(&pIn fo,sizeof(pInfo ));
sInfo.cb=sizeof (sInfo);
sInfo.dwFlags=S TARTF_USESTDHAN DLES;
sInfo.hStdInput =NULL;
sInfo.hStdOutpu t=wPipe;
sInfo.hStdError =wPipe;
char command[1024]; strcpy(command,
csExecute.GetBu ffer(csExecute. GetLength()));
//Create the process here.
if(CreateProces s(0, command,0,0,TRU E,NORMAL_PRIORI TY_CLASS|CREATE _NO_WINDOW,0,0, &sInfo,&pInf o))
{
DWORD retVal = WaitForSingleOb ject(pInfo.hPro cess,IE_MAXWAIT );
if(retVal == WAIT_TIMEOUT)
{
MessageBox(NULL ,"TimeOut","Out put",MB_OK|MB_I CONEXCLAMATION) ;
CloseHandle(pIn fo.hThread);
CloseHandle(pIn fo.hProcess);
}
}
I started one process using CreateProcess() in vc++. Now I want to set wait time out for that created process. Let consider, I am starting notepad using the above function, then I asked to handle that process. In this situation, the Notepad does not return any value. so this handling function still holds. I want to set the wait time, If the time exceed then that handled object should release, I have tried with WaitForSingleOb ject and set my time, the timeout function is encounted but the Handle resource doesnot release, here code snippet....
STARTUPINFO sInfo;
ZeroMemory(&sIn fo,sizeof(sInfo ));
PROCESS_INFORMA TION pInfo;
ZeroMemory(&pIn fo,sizeof(pInfo ));
sInfo.cb=sizeof (sInfo);
sInfo.dwFlags=S TARTF_USESTDHAN DLES;
sInfo.hStdInput =NULL;
sInfo.hStdOutpu t=wPipe;
sInfo.hStdError =wPipe;
char command[1024]; strcpy(command,
csExecute.GetBu ffer(csExecute. GetLength()));
//Create the process here.
if(CreateProces s(0, command,0,0,TRU E,NORMAL_PRIORI TY_CLASS|CREATE _NO_WINDOW,0,0, &sInfo,&pInf o))
{
DWORD retVal = WaitForSingleOb ject(pInfo.hPro cess,IE_MAXWAIT );
if(retVal == WAIT_TIMEOUT)
{
MessageBox(NULL ,"TimeOut","Out put",MB_OK|MB_I CONEXCLAMATION) ;
CloseHandle(pIn fo.hThread);
CloseHandle(pIn fo.hProcess);
}
}
Comment