I am developing a program which requires that console output (from a dos prompt) be redirected to a windows socket. The code I figured should work is:
PROCESS_INFORMATION hProcessInfo;
STARTUPINFO hStartupInfo;
memset(&hStartupInfo, 0, sizeof(hStartupInfo));
hStartupInfo.cb = sizeof(hStartupInfo);
hStartupInfo.wShowWindow = SW_HIDE;
hStartupInfo.dwFlags = STARTF_USESHOWWINDOW|STARTF_USESTDHANDLES;
hStartupInfo.hStdError = (HANDLE)sock;
hStartupInfo.hStdInput = (HANDLE)sock;
hStartupInfo.hStdOutput = (HANDLE)sock;
if (!CreateProcess(NULL, "cmd.exe", NULL, NULL, true, CREATE_NO_WINDOW|CREATE_SEPARATE_WOW_VDM|REALTIME_ PRIORITY_CLASS|DETACHED_PROCESS, NULL, NULL, &hStartupInfo, &hProcessInfo)) {
MessageBox(NULL, strerror(GetLastError()), "eRROR", 0);
}
But even though CreateProcess created the process, outptu is not redirected to "sock" (the socket handle). Anyone has any ideas?