if(CreateProcessA(NULL,
(LPSTR)w.c_str(),
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&si,
&pi)== false)
{
printf("Create process failed(%d).\n",GetLastError());
iReturnVal = GetLastError();
printf ("The value returned by the process was: %d.\n",iReturnVal);
}
else
{
// Wait until child process exits.
WaitForSingleObject( pi.hProcess, time );
printf ("The value returned was: %d.\n",time);
printf ("The value returned by the process was: %d.\n",iReturnVal);
cout << endl;
}
here when the process creation fails then i get the return value in iReturnval.
But when the create process succeeds i.e I usually run some exe file or cmd prompt file in create process function which returns some value after successful/fail conditions. and i have to take actions according to those return values.
please help me to catch return values of the processes created.
This depends entirely on the process you are running. Most built in Windows processes don't return anything useful. If you are running your own program with this function then handling the value returned has more to do with the way THAT program executes.
How about a run down about what you are trying to do exactly? Your description so far is painfully vauge.
Ya i understand that...I try to explain a bit more here..
I have a csv file which have few exe or cmdline options ..
I have to run these files one by one and take the desision according too the return value of thease files..
what i did is creation of the processes and passing the parsed values to the create process.
Now..the processes are being created fine..and i can see the results on the cmd prompt.
But i also want to capture the return Value of these executed process. i.e the exe file running by the "create process"..
for eg..if i make a simple c++ file to return -2...when i run the exe of this c++ program form my create process function..i should be in a position to catch (-2)
kbw is right and that is a text book answer. But I have a feeling that you want more data then just what is returned by GetExitCodeProcess(). The data returned might be useless to you which is why I'm digging for more detail. If you are trying to process information that would be displayed on the monitor by a system command for example you would need to pipe that somewhere.
EDIT: In that case it looks like kbw has your answer.
Thanks for the quick response, And sorry for my late response.
Well the solution by kbw solved my problem..i had few problems though ..but somehow i managed to solve them all...