在Windows资源管理器中选择文件并不总是有效 [英] Selecting file in Windows Explorers does not always work

查看:123
本文介绍了在Windows资源管理器中选择文件并不总是有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用以下

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

我可以打开Windows资源管理器并选择文件。在Delphi中,我选择 Parm文件:

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);

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

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?

推荐答案

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

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.

您将必须使用 SHOpenFolderAndSelectItems 代替。此功能还允许多选。

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

这篇关于在Windows资源管理器中选择文件并不总是有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆