예제 #1
0
파일: Desktop.cs 프로젝트: stuart2w/SAW
 /// <summary>Fills Programs with all currently visible windows</summary>
 public void PopulateFromWindows()
 {
     Programs.Clear();
     if (!Windows.EnumDesktopWindows(IntPtr.Zero, EnumWindowsIntoProgramsList, IntPtr.Zero))
     {
         throw new UserException("[SAW_Desktop_Failed]", true);
     }
 }
예제 #2
0
파일: Desktop.cs 프로젝트: stuart2w/SAW
 /// <summary>Returns the first visible window for the process or IntPtr.Zero if none, with optional error message in out param </summary>
 public static IntPtr FindWindowForProcess(IntPtr processID, out string errorMessage)
 {
     errorMessage = null;
     g_FoundHWND  = IntPtr.Zero;
     if (!Windows.EnumDesktopWindows(IntPtr.Zero, EnumWindowsFindForProcess, processID))
     {
         errorMessage = $"FindWindowForProcess failed with code {Marshal.GetLastWin32Error()}.";
     }
     return(g_FoundHWND);
 }