命令行下用重定向是可以的.不要用system()哦,它会产生一个黑框框.大家帮忙啊!!!
解决方案 »
- 在什么地方合适delete
- MFC 文本框大小问题
- 选择文件和文件夹对话框怎么实现?
- 关于如何绘制透明位图的问题.
- 一个秘密!!!
- 怎么 STD::string 这么不好用????
- 关于注册表函数RegEnumValue()如何正确使用?(请确实使用过的高手解答,我问多次,却无人解答!!)
- 如何实现画图板中的bmp保存?
- 请大家帮帮忙^_^
- 请问如何用Brush在按钮上刷背景?
- AfxMessageBox 消息框对应的 classname 是什么?
- 链接错误nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in libcpd
_execl("a.exe", "a.exe", ">list.txt", NULL);
不管用啊. 大家帮忙哈!
#include <afx.h>void main()
{
CStdioFile file;
CString str="\n这是我要添加在最后面的一行。";
file.Open("f:\\text.txt",CStdioFile::modeReadWrite);
file.SeekToEnd();
file.WriteString((LPCSTR)str); //自己打开这个文件查看一下,呵呵,偷个懒
file.Close();
}
GetStdHandle
ReadConsoleOutput
函数吧
#include <stdio.h>
#include <process.h>int main()
{
FILE* fp=fopen("list.txt", "w");
_dup2(_fileno(fp),1);
_spawnl(_P_WAIT, "hello.exe", "hello.exe", NULL);
fclose(fp);
return 0;
}//hello.c, produce hello.exe
#include <stdio.h>int main()
{
printf("Hello,world!\n");
return 0;
}
void CDosWindowsDlg::OnButton1()
{
// TODO: Add your control notification handler code here
SECURITY_ATTRIBUTES sa;
HANDLE hRead,hWrite;
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = TRUE;
if (!CreatePipe(&hRead,&hWrite,&sa,0)) {
MessageBox("Error On CreatePipe()");
return;
}
STARTUPINFO si;
PROCESS_INFORMATION pi;
si.cb = sizeof(STARTUPINFO);
GetStartupInfo(&si);
si.hStdError = hWrite;
si.hStdOutput = hWrite;
si.wShowWindow = SW_HIDE;
si.dwFlags = STARTF_USESHOWWINDOW ¦ STARTF_USESTDHANDLES;
if (!CreateProcess(NULL,"cmd.exe /c dir /?"
,NULL,NULL,TRUE,NULL,NULL,NULL,&si,&pi)) {
MessageBox("Error on CreateProcess()");
return;
}
CloseHandle(hWrite);
char buffer[4096] = {0};
DWORD bytesRead;
while (true) {
if (ReadFile(hRead,buffer,4095,&bytesRead,NULL) == NULL)
break;
m_Edit1 += buffer;//m_Edit1是CString
UpdateData(false);
Sleep(200);
}
}