Well. The solution was so extremely trivial that it stuns me. I've tried various things like using WinApi hooks to hook into explorer.exe and ShellExecute WinApi calls and a managed wrapper. Then I thought about screenshot analysis :/
As I am using White for my WPF UI tests, which itself relies heavily on Microsoft's great UIAutomation framework and UIAutomation can do nearly everything I just needed to locate a window by means of automation:
var desktop = AutomationElement.RootElement;
foreach (AutomationElement element in desktop.FindAll(TreeScope.Children, Condition.TrueCondition))
{
if (element.Current.ClassName != "CabinetWClass")
{
continue;
}
Console.WriteLine("{0}, {1}",element.Current.Name, element.Current.ClassName);
}
Do not forget to add UIAutomationClient and UIAutomationTypes assemblies and using System.Windows.Automation;