SECURITY_ATTRIBUTES sa = {12, NULL, TRUE}; // Let child process inherit handles (specifically hStdoutWrite) HANDLE hPipeRead, hPipeWrite; if (!CreatePipe(&hPipeRead, &hPipeWrite, &sa, 0)) { // moan, bitch, and whine } STARTUPINFO si = {68, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES, 0, 0, NULL, NULL, NULL}; si.hStdOutput = hPipeWrite; si.hStdError = hPipeWrite; PROCESS_INFORMATION pi; if (!CreateProcess(NULL, "cmd /c dir", &sa, &sa, TRUE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi)) { // moan, bitch, and whine } CloseHandle(hPipeWrite); // then use ReadFile to read from hPipeRead