예제 #1
0
 public static IEnumerable <string> WindowTitlesForClass(string className)
 {
     foreach (var windowHandle in WindowsMatchingClassName(className))
     {
         var length = Win32Interop.GetWindowTextLength(windowHandle);
         var sb     = new StringBuilder(length + 1);
         Win32Interop.GetWindowText(windowHandle, sb, sb.Capacity);
         yield return(sb.ToString());
     }
 }
예제 #2
0
 public static IEnumerable <IntPtr> FindWindowByTitle(this IEnumerable <IntPtr> handles, string title)
 {
     return(handles.Where(windowHandle =>
     {
         var length = Win32Interop.GetWindowTextLength(windowHandle);
         var sb = new StringBuilder(length + 1);
         Win32Interop.GetWindowText(windowHandle, sb, sb.Capacity);
         if (sb.ToString() == title)
         {
             return true;
         }
         return false;
     }));
 }