在 Windows 资源管理器中选择文件并不总是有效

发布于 2024-10-04 21:25:15 字数 445 浏览 0 评论 0原文

使用以下命令

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

我可以打开 Windows 资源管理器并选择文件。在 Delphi 中,我这样做是为了选择“Parm”文件:

ShellExecute(Application.MainForm.Handle, 'OPEN', PChar('explorer.exe'), PChar('/select,"' + Parm + '"'), nil, SW_NORMAL);

并且它有效。我的问题是这样的:如果我在最近打开的资源管理器中选择不同的文件(单击不同的文件),然后调用上面的代码,则不会再次选择“Parm”文件。有趣的是,有些程序会再次选择文件。例如,iTunes 总是选择所需的文件。

有谁知道如何让资源管理器始终选择指定的文件?

Using the following

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

I can open Windows Explorer and select the file. In Delphi I do this to select "Parm" file:

ShellExecute(Application.MainForm.Handle, 'OPEN', PChar('explorer.exe'), PChar('/select,"' + Parm + '"'), nil, SW_NORMAL);

And it works. My problem is this: if I select a different file in the recently opened Explorer (clicking in a different file) and then call the above code the "Parm" file is not selected again. Interestingly, there are some programs that select the file again. For instance, ITunes always selects the desired file.

Does anyone have a clue of how to make Explorer always select the specified file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小…楫夜泊 2024-10-11 21:25:15

这是在 explorer.exe 中使用 /select 开关的一个已知限制,如果父文件夹尚未打开,它将仅选择特定文件。

您必须使用 API 调用,例如 SHOpenFolderAndSelectItems 相反。此功能还允许多选。

This is a known limitation of using the /select switch with explorer.exe, it will only select the specific file if the parent folder is not already open.

You'll have to use an API call like SHOpenFolderAndSelectItems in stead. This function also allows for multiselect.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文