windows - 以编程方式在 Windows 资源管理器中选择多个文件

标签 windows explorer windows-shell

我可以像这样在 Windows 资源管理器中显示和选择单个文件:

explorer.exe /select, "c:\path\to\file.txt"

但是,我不知道如何选择多个文件。我尝试过的 select 排列均无效。

注意:我查看了这些页面的文档,但都没有帮助。

https://support.microsoft.com/kb/314853
http://web.archive.org/web/20100716112458/http://www.infocellar.com:80/Win98/explorer-switches.htm

最佳答案

这应该可以通过 shell 函数 SHOpenFolderAndSelectItems 实现

编辑

下面是一些示例代码,展示了如何在 C/C++ 中使用该函数,不进行错误检查:

//Directory to open
ITEMIDLIST *dir = ILCreateFromPath(_T("C:\\"));

//Items in directory to select
ITEMIDLIST *item1 = ILCreateFromPath(_T("C:\\Program Files\\"));
ITEMIDLIST *item2 = ILCreateFromPath(_T("C:\\Windows\\"));
const ITEMIDLIST* selection[] = {item1,item2};
UINT count = sizeof(selection) / sizeof(ITEMIDLIST);

//Perform selection
SHOpenFolderAndSelectItems(dir, count, selection, 0);

//Free resources
ILFree(dir);
ILFree(item1);
ILFree(item2);

关于windows - 以编程方式在 Windows 资源管理器中选择多个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9355/

相关文章:

Windows 上的 Python 包 : pip or native installers?

c - 如何在打开特定文件夹时自动启动程序

iOS 文件浏览器示例

c++ - 注册特定文件扩展名的 Windows shell 命名空间文件夹 View 扩展名

c++ - "Shell Namespace"新建文件夹的方法是什么?

python - 如何从 ctypes 使用 IFileOperation

c# - 如何使用 C# 检测何时插入可移动磁盘?

windows - 在 Windows 7 机器上进行 Hadoop 开发是否有很好的在线教程?

windows - 如何以编程方式刷新 Windows 资源管理器?

mongodb - 无法在 Mongo Explorer 中添加服务器(Atlas Cluster)