1
我有免費的大膽項目,其代碼可用於計算voronoy網格,初始化freeglut並繪製網格。無法從freeGlut項目獲得stdoutput
pre-calculations
...
printf("Elapsed %lf seconds\n", (double)(clock() - start)/CLOCKS_PER_SEC);
glutInit (&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize (WIDTH, HEIGHT);
// create window
glutCreateWindow ("Voronoy");
// register handlers
glutDisplayFunc (display);
glutReshapeFunc (reshape);
glutKeyboardFunc (key );
glutMainLoop();
return 0;
...
所以程序在控制檯模式下工作,然後創建freeglut窗口。 而且我有單獨的程序,從連接到這個stdout管道讀取。我用這個參數創建過程
STARTUPINFO si;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
si.dwFlags = STARTF_USESTDHANDLES;
si.hStdInput = stdinput.ReadPipe();
si.hStdOutput = stdoutput.WritePipe();
si.hStdError = stderror.WritePipe();
stdoutput.DuplicateReadPipe();
if (!CreateProcess("j:\\Projects\\study\\fortune\\Debug\\voronoy.exe",//"C:\\GnuWin32\\bin\\ls.exe",
NULL,
NULL, NULL,
TRUE,
(CREATE_SUSPENDED | CREATE_SEPARATE_WOW_VDM | CREATE_NO_WINDOW),
NULL, NULL,
&si, &process_info))
{
throw("!!!");
}
DWORD w = ResumeThread(process_info.hThread);
CloseHandle(process_info.hProcess);
CloseHandle(process_info.hThread);
而且我也嘗試過使用MSDN的標準Pipes示例。
問題是程序沒有從管道接收數據。 我也嘗試了cmd.exe中的voronoy.exe> test.txt,並且test.txt保持爲空。 但如果我沒有管道運行它 - 它工作正常,我可以在控制檯中看到輸出。