打开Windows资源管理器目录,选择一个特定的文件(在delphi中)
发布时间:2020-12-14 04:34:07 所属栏目:Windows 来源:网络整理
导读:我有一个过程在 Windows资源管理器中打开一个文件夹,通过一个目录路径: procedure TfrmAbout.ShowFolder(strFolder: string);begin ShellExecute(Application.Handle,PChar('explore'),PChar(strFolder),nil,SW_SHOWNORMAL);end; 有没有办法通过这个文件名(
我有一个过程在
Windows资源管理器中打开一个文件夹,通过一个目录路径:
procedure TfrmAbout.ShowFolder(strFolder: string); begin ShellExecute(Application.Handle,PChar('explore'),PChar(strFolder),nil,SW_SHOWNORMAL); end; 有没有办法通过这个文件名(完整的文件名路径或只是名称扩展名),并在Windows资源管理器中打开该文件夹,但也被突出显示/选择?我将要有多个文件的位置,然后我需要在Windows中操作该文件.
是的,您可以在调用explorer.exe时使用
/select flag:
ShellExecute(0,'explorer.exe','/select,C:WINDOWSexplorer.exe',SW_SHOWNORMAL) 一个更有趣(也许更可靠)的方法(使用ShellAPI,ShlObj): const OFASI_EDIT = $0001; OFASI_OPENDESKTOP = $0002; {$IFDEF UNICODE} function ILCreateFromPath(pszPath: PChar): PItemIDList stdcall; external shell32 name 'ILCreateFromPathW'; {$ELSE} function ILCreateFromPath(pszPath: PChar): PItemIDList stdcall; external shell32 name 'ILCreateFromPathA'; {$ENDIF} procedure ILFree(pidl: PItemIDList) stdcall; external shell32; function SHOpenFolderAndSelectItems(pidlFolder: PItemIDList; cidl: Cardinal; apidl: pointer; dwFlags: DWORD): HRESULT; stdcall; external shell32; function OpenFolderAndSelectFile(const FileName: string): boolean; var IIDL: PItemIDList; begin result := false; IIDL := ILCreateFromPath(PChar(FileName)); if IIDL <> nil then try result := SHOpenFolderAndSelectItems(IIDL,0) = S_OK; finally ILFree(IIDL); end; end; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows-server-2012-r2 – 取消WSUS下载过程
- active-directory – 使Active Directory更改为原子
- windows-phone-7 – ListBox选择时禁用高亮显示 – Windows
- 触发Windows UAC提示时是否有WinAPI消息?
- windows-server-2008 – 如果/ bin更改,我可以阻止IIS回收吗
- windows – 用于Microsoft Loopback Adapter的是什么?
- 存储过程 – 如何在IBM System i Access for Windows GUI T
- iis – Windows防火墙IP禁令?
- windows-phone-7 – 出于性能原因正确处理Tombstoning和Bac
- windows10下基于docker的bvlc/caffe环境搭建与使用
推荐文章
站长推荐
- windows-installer – 如何在Installshield 2018
- microsoft-office-365-将office365企业办公室201
- 配备Hyper-V的智能UPS 2200和Windows 2008 R2
- SecureCRT_FX 8.3.3 x86 & x64 (带注册机)下
- tfs – MSBuild将因Windows Workflow而死亡?
- windows – 查询线程(不处理)处理器关联?
- Windows – Visual Studio 2012“无效的许可证数
- Windows服务恢复不重新启动服务
- 从本机dll生成C#DLLImport声明
- windows – 如何增加apache连接限制? (WAMP)
热点阅读