Thanks
You can use the ShellWindows object to enumerate the collection of shell windows. Each item is an InternetExplorer object that supports an "HWND" property, which you could use to determine whether it is the active window. If the item is a normal Explorer window then the "Document" property exposes an IShellFolderViewDual2 interface, which provides a SelectedItems method allowing you to get the path of any selected items.
ShellWindows Object: http://msdn.microsoft.com/en-us/library/bb773974.aspx
InternetExplorer Object: http://msdn.microsoft.com/en-us/library/aa752084.aspx
ShellFolderView Object: http://msdn.microsoft.com/en-us/library/bb774049.aspx
--
Jim Barry, Microsoft MVP
The idea of an IE object with folders is misleading. It's a leftover
from the days of Active Desktop and WebView, when MS
was desperately trying to make Windows look Web-integrated
and "hip". On pre-XP systems there actually is an IE
browser window in folder windows. On XP, Shell.Windows
returns dummy IE instances for folders -- WebView was
removed in XP -- but the dummy still works for your purpose.
On all systems the dummy IE.Document returns not a real IE
Document object but rather a ShellFolderView object. (It
takes an extra step to get the actual IE Document object
that exists on WebView systems.)
The SFV is a COM wrapper around the ListView window
that actually displays files in a folder window. The whole
Shell object model is a bit convoluted and piecemeal, but SFV
does have a SelectedItems collection that you can use.
If you can work with VB code (not VB.Net), see here:
www.jsware.net/jsware/vbcode.php5#shlop
It's a VB project that demostrates 3 different ways to
get at a folder's selected items:
1) Getting a ShellFolderView as an embedded object on
the folder.htt webpage on pre-XP systems -- works on
Win95 -> 2000 with Active Desktop.
2) Getting a ShellFolderView from the dummy IE.Document
available via Shell.Windows -- should work on all systems
but requires Active Desktop update on Win95/NT4.
3) Getting selected items through Active Accessibility,
which is in oleacc.dll. Oleacc.dll is available since Win98SE.
Thank you both very much! this was very helpful.