private GetWindowText ( |
||
hWnd | ||
lpString | StringBuilder | |
nMaxCount | int | |
return | int |
/// <summary> /// Callback function for the enumwindows function /// </summary> /// <param name="winHandle">enumerated window handle</param> /// <param name="lParam">nod used </param> /// <returns></returns> private static bool enumWindowsCallback(IntPtr winHandle, int lParam) { if (!User32Interop.IsWindowVisible(winHandle)) { return(true); } if (_excludeThisProcess) { uint pid = 0; User32Interop.GetWindowThreadProcessId(winHandle, out pid); if (pid == 0 || pid == _currentProcess.Id) { return(true); } } if (!Windows.IsApplicationWindow(winHandle)) { return(true); } if (!canBeActivated(winHandle)) { return(true); } if (Windows.IsCloakedWindow(winHandle)) { return(true); } var buffer = new StringBuilder(1024); User32Interop.GetWindowText(winHandle, buffer, buffer.Capacity); var windowTitle = buffer.ToString(); // save the window only if it is visible and contains a title // and has an app icon (this criterium is needed to not display "Start" and "Program Manager") // this can be altered in the future to add other filtering criteria if (!string.IsNullOrEmpty(windowTitle)) { Log.Debug("hWnd=" + winHandle + " windowTitle=" + windowTitle); var info = new WindowInfo(winHandle, windowTitle); windowList.Add(info); } // return true to continue enumerating windows. return(true); }
/// <summary> /// Callback function for the enumwindows function /// </summary> /// <param name="winHandle">enumerated window handle</param> /// <param name="lParam">nod used </param> /// <returns></returns> private static bool enumWindowsCallback(IntPtr winHandle, int lParam) { var buffer = new StringBuilder(1024); User32Interop.GetWindowText(winHandle, buffer, buffer.Capacity); var windowTitle = buffer.ToString(); // save the window only if it is visible and contains a title // and has an app icon (this criterium is needed to not display "Start" and "Program Manager") // this can be altered in the future to add other filtering criteria if (User32Interop.IsWindowVisible(winHandle) && (!string.IsNullOrEmpty(windowTitle)) && (GetAppIcon(winHandle) != null)) { Log.Debug("hWnd=" + winHandle + " windowTitle=" + windowTitle); var info = new WindowInfo(winHandle, windowTitle); windowList.Add(info); } // return true to continue enumerating windows. return(true); }