开发者

Get selected items from explorer using C# .NET 3.5

开发者 https://www.devze.com 2022-12-22 22:53 出处:网络
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 foregro开发者_C百科und.

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 foregro开发者_C百科und.

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


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)


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消