第一种为FILE *_popen( const char *command, const char *mode); 第一个参数直接传命令,返回端直接为管道的句柄,用fget来提取文件信息。
贴出关键代码:
WideCharToMultiByte(CP_ACP, 0, strCmmdLine.GetBuffer(), strCmmdLine.GetLength(), path, MAX_PATH-1, NULL, NULL);
//注意,命令行参数必须为ASCII字符
if( (child_output = _popen(path, "rt" )) == NULL )
return 1;
while(!feof( child_output ) )
{
if( fgets( psBuffer, 1023, child_output ))
{
// 将子进程的标准输出写入管道,提......
阅读全文