我在 Delphi 项目中有一个表单。表格上有一个按钮。当用户单击该按钮时,我希望它打开 Windows 资源管理器。
我需要什么代码来实现这个?
最佳答案
如果您需要在资源管理器中选择某个特定文件,我可以使用以下功能
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 添加到您的使用列表中
关于windows - 单击按钮时如何打开 Windows 资源管理器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1261482/