用ShellExecute("open",...)能在资源管理器中打开一个目录,但不知如何选中某个文件?

解决方案 »

  1.   


    19 问:如何在打开一个文件夹(ShellExecute),同时选中某个指定的文件 ?答:
    方法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.
    方法3 使用Windows XP提供的SHOpenFolderAndSelectItems函数