如何在打开一个文件夹(ShellExecute),同时选中某个指定的文件 ?

Frank0233 2004-06-18 07:44:42
例如d盘有个help.htm文件
我通过ShellExecute(NULL,"open","D:\\",NULL,NULL,SW_SHOW);
把文件浏览窗口打开,但是如何让help.htm这个文件获得焦点呢?
...全文
971 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Frank0233 2004-06-27
  • 打赏
  • 举报
回复
good!
Smallfrogs 2004-06-18
  • 打赏
  • 举报
回复
直接使用Explorer.exe的/Select参数指定就行

蒋晟 2004-06-18
  • 打赏
  • 举报
回复
方法1 自动化资源管理器,创建一个Explorer对象,然后用IShellBrowser和IShellView借口控制
方法2 记得Explorer.exe有个/select参数
[Windows Explorer Switches]
Windows Explorer switches are useful in creating rooted folders:

Explorer [/e][,/root,<object>][[,/select],<sub object>]

/e
Use Explorer view (scope and results pane view). The default is
Open view (results in pane view only).

/root<object>
Specify the object in the "normal" name space that is
used as the root (top level) of this Explorer/Folder (i.e., local
path or UNC name). The default is the Desktop).
/Select
The parent folder opens and the specified object is selected.
<sub object> Specify the folder unless /select is used. The
default is the root.

Examples:Explorer /e, /root, \\Reports

opens an Explorer window at \\Reports.

Explorer /select, C:\Windows\Calc.exe

opens a folder at C:\Windows (or activates one that is
currently open) and selects Calc.exe.


Explorer/e,/root,\\Source\Internal\Design\Users\David\Archive

opens a folder to the Archive folder above. This is a good
way to create a dedicated, remote, documents archive
folder. A link to this folder (\\Source\Internal\Design\
Users\David\Archive) can then be placed in the SendTo folder
for quick routing of documents.
nightfallrove 2004-06-18
  • 打赏
  • 举报
回复
ShellExecute(NULL, "open", "D:\\help.htm", NULL, NULL, SW_SHOW);
nightfallrove 2004-06-18
  • 打赏
  • 举报
回复
你直接打开这个文件不行吗?
ShellExecute(NULL, "open", "D:\\", NULL, NULL, SW_SHOW);
怎么让它获得焦点我也不会。

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧