2009-08-11 92 views

回答

8

试试这个:

ShellExecute(Application.Handle, nil, 'explorer.exe', nil, nil, SW_NORMAL); 

你需要添加ShellAPI使用条款。

10

建立在什么梅森惠勒说:你还可以在一个目录作为参数传递,获取窗口打开到非默认位置:好万一

uses 
    ShellAPI; 

... 

    ShellExecute(Application.Handle, 
    nil, 
    'explorer.exe', 
    PChar('c:\'), //wherever you want the window to open to 
    nil, 
    SW_NORMAL  //see other possibilities by ctrl+clicking on SW_NORMAL 
    ); 
22

你需要选择一些在资源管理器特定的文件我有以下的功能,我使用

procedure SelectFileInExplorer(const Fn: string); 
begin 
    ShellExecute(Application.Handle, 'open', 'explorer.exe', 
    PChar('/select,"' + Fn+'"'), nil, SW_NORMAL); 
end; 

,你可以把它叫做:

SelectFileInExplorer('C:\Windows\notepad.exe'); 

编辑:如前所述ShellAPI的必须添加到您的应用列表

+1

非常酷,我还没有看到之前 – JosephStyons 2009-08-11 17:02:05

+0

这将工作,如果该文件不在C:\ ?? – Zeina 2015-05-18 11:53:34

+0

是的,它可以在任何有效的窗口路径上工作 – zz1433 2015-05-18 16:48:02

相关问题