重定向输入输出问题
本人编写的一个windows程序需要检查另一个console程序在指定输入的情况下的输出,并检查该console程序的运行时间。因此使用的是CreateProcess来创建子进程,该API中有个LPSTARTUPINFO类型的参数,其定义为:
typedef struct _STARTUPINFOA {
DWORD cb;
LPSTR lpReserved;
LPSTR lpDesktop;
LPSTR lpTitle;
DWORD dwX;
DWORD dwY;
DWORD dwXSize;
DWORD dwYSize;
DWORD dwXCountChars;
DWORD dwYCountChars;
DWORD dwFillAttribute;
DWORD dwFlags;
WORD wShowWindow;
WORD cbReserved2;
LPBYTE lpReserved2;
HANDLE hStdInput;
HANDLE hStdOutput;
HANDLE hStdError;
} STARTUPINFOA, *LPSTARTUPINFOA;
请问应该如何给hStdInput和hStdOutput赋值从而达到重定向输入输出的目的。
不胜感激。