在C程序中用system函数调用了另一个可执行程序,结果dos命令的黑色框也出来了,怎么能去掉

来源:百度知道 编辑:UC知道 时间:2024/06/21 09:01:29
C程序中想调用另一个可执行文件,我进行了如下操作
system("D:\\DRX\\MPEGView\\MPEGView.exe");
结果是运行了MPEGView.exe; 可是dos的命令框也出来了,
有什么办法只运行exe文件,没有其他东西跳出?

这个命令肯定会出现dos窗口的,要不你选择CreateProcess方法,可以避免这个问题。
BOOL CreateProcess(
LPCTSTR lpApplicationName, // name of executable module
LPTSTR lpCommandLine, // command line string
LPSECURITY_ATTRIBUTES lpProcessAttributes, // SD
LPSECURITY_ATTRIBUTES lpThreadAttributes, // SD
BOOL bInheritHandles, // handle inheritance option
DWORD dwCreationFlags, // creation flags
LPVOID lpEnvironment, // new environment block
LPCTSTR lpCurrentDirectory, // current directory name
LPSTARTUPINFO lpStartupInfo, // startup information
LPPROCESS_INFORMATION lpProcessInformation // process information
);
把dwCreationFlags这个参数设置为CREATE_NO_WINDOW
这个对console程序有效,对纯DOS下的程序无效
这个方法还可以让调用的程序执行完以后再执行主程序。