1,控制台程序示例代码
int _tmain(int argc, _TCHAR* argv[])
{
// 参数个数,第一个参数为可执行文件路径
int iParamCount = argc;
cout<<"参数个数:"<<iParamCount<<endl;
for( int i = 0; i < iParamCount; i++)
{
cout<<endl<<"第"<<i+1<<"个参数:";
wprintf(argv[i]);
}
getchar();
return 0;
}
2,使用ShellExecuteEx调用控制台程序(exe)并传入多个参数,多个参数之间以空格隔开
SHELLEXECUTEINFO ShellInfo;
memset(&ShellInfo, 0, sizeof(ShellInfo));
ShellInfo.cbSize = sizeof(ShellInfo);
ShellInfo.hwnd = NULL;
ShellInfo.lpVerb = _T("open");
ShellInfo.lpFile = _T("D:\\test\\ShellExecuteEx\\debug\\image.exe"); // 此处写执行文件的绝对路径
ShellInfo.lpParameters = _T("D:\\a.txt D:\\b.txt");
ShellInfo.nShow = SW_SHOWNORMAL;
ShellInfo.fMask = SEE_MASK_NOCLOSEPROCESS;