【前言】
在mfc工程中调用CMD执行一些功能,对实现某些功能非常方便,例如,调用本地的.exe(可执行文件)或者运行.bat(批处理文件)。
平台:visual studio 2010 + windows系统 + MFC工程
【正文】
一、几种常见的方法
1)system
原型如下:
[stdlib.h]
#ifndef _CRT_SYSTEM_DEFINED
#define _CRT_SYSTEM_DEFINED
_CRTIMP int __cdecl system(_In_opt_z_ const char * _Command);
#endif
2)WinExec
[WinBase.h]
WINAPI
WinExec(
__in LPCSTR lpCmdLine,
__in UINT uCmdShow
);