Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open windows explorer when I click a button?

I have a form in a Delphi project. There is a button on the form. When the user clicks the button, I want it to open Windows Explorer.

What code will I need to achieve this?

like image 597
Tobassum Munir Avatar asked Aug 11 '09 16:08

Tobassum Munir


People also ask

How do I open Windows Explorer click?

File Explorer in Windows 11 helps you get the files you need quickly and easily. To check it out in Windows 11, select it on the taskbar or the Start menu, or press the Windows logo key + E on your keyboard.

What is the shortcut key to open Windows Explorer?

To open the File Explorer window, simply press the Windows button ⊞ + E .

How do I get Windows Explorer to open again?

Press Ctrl+Shift+Esc to open the Task Manager, then right-click Windows Explorer and select "Restart" to restart Windows Explorer. On Windows 7, 8, or 10, you can also right-click the taskbar while holding Ctrl+Shift and select "Exit Explorer" to restart Windows Explorer.


1 Answers

Well in case you need to select some particular file in explorer I have the following function which I use

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

and you can call it :

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

EDIT: As mentioned ShellAPI must be added to your uses list

like image 178
zz1433 Avatar answered Oct 05 '22 17:10

zz1433