Widow – Blame information for rev 7

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 using System;
2 using System.Collections.Generic;
3 using System.Diagnostics;
4 using System.Text;
5  
6 namespace Widow
7 {
8 public static class Helpers
9 {
10 #region Public Methods
11  
12 public static IEnumerable<DesktopWindow> GetDesktopWindows()
13 {
14 foreach (var process in Process.GetProcesses())
15 {
16 yield return new DesktopWindow(process.MainWindowHandle, process.MainWindowTitle);
17 }
18 }
19  
20 public static IntPtr FindWindowByTitle(string name)
21 {
22 var hWnd = IntPtr.Zero;
23 foreach (var pList in Process.GetProcesses())
24 {
25 if (pList.MainWindowTitle.Contains(name))
26 {
27 hWnd = pList.MainWindowHandle;
28 }
29 }
30  
31 return hWnd;
32 }
33  
34 public static string GetWindowTitle(IntPtr hWnd)
35 {
36 var length = Natives.GetWindowTextLength(hWnd) + 1;
37 var title = new StringBuilder(length);
38 Natives.GetWindowText(hWnd, title, length);
39 return title.ToString();
40 }
41  
42 #endregion
43 }
44 }