如何解析由“CreateProcess”创建的子进程的输出字符串

时间:2013-09-05 15:45:05

标签: c windows winapi

我在代码中执行.exe。像:

if( !CreateProcess( NULL,   // No module name (use command line)
    "sub.exe 2",    // Command line
    NULL,           // Process handle not inheritable
    NULL,           // Thread handle not inheritable
    FALSE,          // Set handle inheritance to FALSE
    0,              // No creation flags
    NULL,           // Use parent's environment block
    NULL,           // Use parent's starting directory 
    &si,            // Pointer to STARTUPINFO structure
    &pi )           // Pointer to PROCESS_INFORMATION structure
) 

sub.exe简单地将给定值乘以3.这样我就得到6

如何在我的进一步代码中获取响应的字符串?

1 个答案:

答案 0 :(得分:2)

请参阅以下Microsoft示例,了解如何通过管道捕获标准输出和错误:

相关问题