当前位置:   article > 正文

使用ShellExecute通过外部程序一次性打开多个文件_通过 shell 上下文菜单作为参数打开多个文件

通过 shell 上下文菜单作为参数打开多个文件

网上有很多使用ShellExecute打开单个文件的示例,有段时间需要使用到ps一次性打开多张图片,使用方法记录如下

	QString PsExePath = g_pConfig->getPsFullPath();
	std::wstring operate = QString("runas").toStdWString();//临时提升管理员权限
	QString strArg;
	for (int i = 0; i < temp_path.size(); i++)
	{
		strArg += QDir::toNativeSeparators(temp_path[i]);//正斜杠(除法符号/)转反斜杠
		if (i != temp_path.size() - 1)
		{
			strArg = strArg + " ";//每个文件之间用空格分开
		}
	}

	int ret = (int)ShellExecute(nullptr, operate.c_str(), PsExePath.toStdWString().c_str(), strArg.toStdWString().c_str(), nullptr, SW_SHOWNORMAL);
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

大概就是这样,每个文件路径之间用空格隔开

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/281870
推荐阅读
相关标签
  

闽ICP备14008679号