2009-08-11 84 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

相關問題