diff --git a/DesktopRestorer/MainWindow.xaml b/DesktopRestorer/MainWindow.xaml
index c1d877e..fc161af 100644
--- a/DesktopRestorer/MainWindow.xaml
+++ b/DesktopRestorer/MainWindow.xaml
@@ -7,7 +7,8 @@
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
-
+
+
diff --git a/DesktopRestorer/MainWindow.xaml.cs b/DesktopRestorer/MainWindow.xaml.cs
index cdf8be7..87d9480 100644
--- a/DesktopRestorer/MainWindow.xaml.cs
+++ b/DesktopRestorer/MainWindow.xaml.cs
@@ -140,10 +140,44 @@ enum ShowWindowCommands
static extern bool SetWindowPlacement(
IntPtr hWnd,ref WINDOWPLACEMENT lpwndpl);
+ delegate bool EnumThreadDelegate(IntPtr hWnd, IntPtr lParam);
+[DllImport("user32.dll")]
+static extern bool EnumThreadWindows(int dwThreadId, EnumThreadDelegate lpfn,
+ IntPtr lParam);
+
+static List EnumerateProcessWindowHandles(int processId)
+{
+ var handles = new List();
+
+ foreach (ProcessThread thread in Process.GetProcessById(processId).Threads)
+ EnumThreadWindows(thread.Id,
+ (hWnd, lParam) => { handles.Add(hWnd); return true; }, IntPtr.Zero);
+
+ return handles;
+}
+
+private const uint WM_GETTEXT = 0x000D;
+
+[DllImport("user32.dll", CharSet = CharSet.Auto)]
+static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam,
+ StringBuilder lParam);
+
+
public MainWindow()
{
InitializeComponent();
+ var processes = Process.GetProcesses();
+
+ TB.Text = string.Join("\n", processes.Select(process => process.ProcessName));
+
+ foreach (var handle in EnumerateProcessWindowHandles(
+ Process.GetProcessesByName("explorer").First().Id))
+ {
+ StringBuilder message = new StringBuilder(1000);
+ SendMessage(handle, WM_GETTEXT, message.Capacity, message);
+ Console.WriteLine(message);
+ }
}
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)