Вот как я это делаю в AutoHotkey:
GetWindowsExplorerSelectedFile(_hWnd)
{
local selectedFiles, file
; I can send ^C and parse Clipboard, but this way don't mess with clipboard at all, seems nicer.
; Warning: with this, you get only what is displayed in Explorer!
; If you kept the default Windows setting of not displaying file extensions (bad idea...),
; you will get partial file names...
ControlGet, selectedFiles, List, Selected Col1, SysListView321, ahk_id %_hWnd%
Loop, Parse, selectedFiles, `n ; Rows are delimited by linefeeds (`n).
{
If (A_Index = 1)
{
file := A_LoopField
}
Else
{
; Indicate that several files are selected, we return only the first one
; but count the total number of selected files, to indicate we return a partial result
ErrorLevel := A_Index
}
}
Return file
}
И я получаю путь от редактирования поля Explorer (который склонен к проблемам могут отсутствовать или могут быть установлены не показывать! полный путь).
Основная идея состоит в том, чтобы спросить элемент управления SysListView32 Explorer, какие выбранные элементы, и получить их.
Теперь, это хак, есть, вероятно, более чистые способы ...
PS .: Также нашел это: Getting ListView items in C# from SysListView32 using SendMessage
Нужна вуду, чтобы заставить его работать на другом процессе ...
Real код на a French site!