使用 C# .NET 3.5 从资源管理器获取所选项目
我正在用 C# 编写 .NET 3.5 WPF 应用程序。此应用程序需要能够在 Windows 资源管理器位于前台时从 Windows 资源管理器中获取所选项目。
我已经有了处理全局 Windows 热键的代码,然后检查前台 IntPtr 是否来自资源管理器。如果是这样,我就能够获取映射到资源管理器的 System.Diagnostics.Process 对象。
此时,我想从资源管理器中获取所选项目的列表。也许我可以调用一个 Windows API 函数来执行此操作?
谢谢你,
- G
I am writing a .NET 3.5 WPF application in C#. This application needs to be able to get the selected items out of Windows explorer when it is in the foreground.
I already have the code working that handles a global Windows hotkey and then checks to see if the foreground IntPtr is from explorer. If so, I am able to obtain the System.Diagnostics.Process object that maps to explorer.
At this point, I would like to obtain the list of selected items from explorer. Perhaps there is a Windows API function that I could pinvoke to do this?
Thank you,
- G
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用剪贴板。
当按下热键时,模拟 ctrl+c 并从剪贴板获取所选文件的路径。 (您还可以备份剪贴板并在事后恢复它,这样如果那里有重要的东西,就不会弄乱)
You could use clipboard for that.
When hotkey gets pressed, emulate ctrl+c and get paths of the selected files from clipboard. (you could also backup clipboard and restore it afterwards so it doesn't mess that up if one has something important there)
我能找到的最好方法是编写一个 shell 扩展来处理这种情况。不幸的是,此功能的大部分现在已被弃用/不推荐用于当前版本的 .NET 和 Windows。
我正在采取不同的路线,通过剪贴板查找项目。
The best I could find was to write a shell extension to handle this case. Unfortunately much of this functionality is now depreciated / not recommended for current versions of .NET and Windows.
I am taking a different route by finding items through the clipboard instead.