I use the following STARTUPINFO structure in my call to CreateProcess. Do I need to call CloseHandle on hStdError and hStdInput after the process ends?
startupInfo.cb = sizeof(startupInfo);
startupInfo.cb = sizeof(si);
startupInfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
startupInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
startupInfo.hStdOutput = NULL;
startupInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
startupInfo.wShowWindow = SW_HIDE;
Since you didn’t open those handles (that’s not what
GetStdHandledoes), you don’t need to close them (maybe you want to close them
for some other reason, but it’s unlikely). (Note: even if you did
open the handles, you don’t have to wait for the process to exit
before you close them: once they are inherited, closing them in parent
process has no effect on the child).
Note that
hStdOutputshould beINVALID_HANDLE_VALUEinstead ofNULL: that’s the convention for passing the absence of a handle inSTARTUPINFO.