VC++_读取SHELL命令结果
2015-09-24 16:50
555 查看
void CFfmpeg_divide_videoDlg::OnButtonBeginDivide() { 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,"D:\\ffmpeg.exe " ,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; UpdateData(false); Sleep(200); } MessageBox(buffer); }
参考资料:
VC中利用匿名管道技术取得DOS或者命令行以及外部程序的输出
在VC中使用Windows管道技术编程
相关文章推荐
- How to access local directory with script executed in oozie?
- Shell脚本编程小结
- shell的本地变量和环境变量
- shell批量杀进程
- Powershell
- 修改Ubuntu默认Shell
- linux终奌站 信息 格式 更改 /etc/bashrc
- 自动上传FTP服务器的shell脚本
- shell中变量类型
- erlang学习笔记(shell命令)
- Linux Shell 通配符、元字符、转义符使用实例介绍
- ubuntu添加用户未指定shell,ll别名等无法是使用
- 上午所学(jvm内存分配和shell排序算法的深入理解)
- shell编程的笔记
- Java基础知识强化57:经典排序之希尔排序(ShellSort)
- shell脚本报错 /bin/bash^M: bad interpreter
- C程序员学bash shell容易掉坑的注意点(未完待续)
- shell tee
- ubuntu让bash文件可以双击运行
- linux脚本:shell, 判断输入参数的个数(命令行)