我可以像这样在 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/