按照网上一个例子是像下面这样,但是运行起来cmd窗口闪了一下就消失了,我想让cmd窗口显示出来,我可以在里面打命令,比如dir,然后通过管道得到输出,请问这样要怎么做?sa.nLength = sizeof(SECURITY_ATTRIBUTES); 
sa.lpSecurityDescriptor = NULL; 
sa.bInheritHandle = TRUE; 
if (!CreatePipe(&hRead,&hWrite,&sa,0))

MessageBox(NULL,"pipe err", "", MB_OK);
}
si.cb = sizeof(STARTUPINFO); 
GetStartupInfo(&si); 
si.hStdError = hWrite; 
si.hStdOutput = hWrite; 
si.wShowWindow = SW_SHOW; 
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES; 
if (!CreateProcess(NULL,"cmd.exe",NULL,NULL,TRUE,NULL,NULL,NULL,&si,&pi))

MessageBox(NULL,"create process err", "", MB_OK);

CloseHandle(hWrite);
while (true)

ReadFile(hRead,buffer,4095,&bytesRead,NULL);
if(bytesRead >0) MessageBox(NULL,buffer,"",MB_OK);
Sleep(200); 
}