cmdriver/src/CMDriver.cxx
///////////////////////////////////////////////////////////////////////
// PrepAndLaunchRedirectedChild
// Sets up STARTUPINFO structure, and launches redirected child.
///////////////////////////////////////////////////////////////////////
PrepAndLaunchRedirectedChild
Sets up STARTUPINFO structure, and launches redirected child.
PrepAndLaunchRedirectedChild Sets up STARTUPINFO structure and launches redirected child .
DWORD PrepAndLaunchRedirectedChild(char** pBuffer,
                                   char* command,
                                   HANDLE hChildStdOut,
                                   HANDLE hChildStdIn,
                                   HANDLE hChildStdErr) {
    PROCESS_INFORMATION pi;
    STARTUPINFO si;
    ZeroMemory(&si,sizeof(STARTUPINFO));
    si.wShowWindow=SW_HIDE;
    si.cb = sizeof(STARTUPINFO);
    si.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;
    si.hStdOutput = hChildStdOut;
    si.hStdInput  = hChildStdIn;
    si.hStdError  = hChildStdErr;
    if (!CreateProcess(NULL,command,NULL,NULL,TRUE,
                       CREATE_NO_WINDOW,NULL,NULL,&si,&pi)) {
        return OutputError(pBuffer,"CreateProcess");
    }
    if (!CloseHandle(pi.hThread)) return OutputError(pBuffer,"CloseHandle");
    return ERROR_SUCCESS;
}
DWORD PrepAndLaunchRedirectedChild ( char * * pBuffer , char * command , HANDLE hChildStdOut , HANDLE hChildStdIn , HANDLE hChildStdErr ) { PROCESS_INFORMATION pi ; STARTUPINFO si ; ZeroMemory ( & si , sizeof ( STARTUPINFO ) ) ; si . wShowWindow = SW_HIDE ; si . cb = sizeof ( STARTUPINFO ) ; si . dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW ; si . hStdOutput = hChildStdOut ; si . hStdInput = hChildStdIn ; si . hStdError = hChildStdErr ; if ( ! CreateProcess ( NULL , command , NULL , NULL , TRUE , CREATE_NO_WINDOW , NULL , NULL , & si , & pi ) ) { return OutputError ( pBuffer , " " ) ; } if ( ! CloseHandle ( pi . hThread ) ) return OutputError ( pBuffer , " " ) ; return ERROR_SUCCESS ; }
PrepAndLaunchRedirectedChild
Sets up STARTUPINFO structure, and launches redirected child.
PrepAndLaunchRedirectedChild Sets up STARTUPINFO structure and launches redirected child .
// Set up the start up info struct. // Launch the process that you want to redirect // Close any unnecessary handles.