/// <summary> /// Returns a list of the running processes that have a window (except this app's process and explorer.exe). /// </summary> /// <param name="previewImageSize">The size of the preview images for the processes.</param> private Process_List GetProcessList(Size previewImageSize) { ScreenCapture capturer = new ScreenCapture(); Process_List processes = new Process_List(); processes.Processes = new List<ProcessDescription>(); foreach (var proc in Process.GetProcesses()) { if (proc.MainWindowHandle == IntPtr.Zero || proc.Id == Process.GetCurrentProcess().Id || proc.ProcessName == "explorer") { continue; } Bitmap bmp = capturer.SnapshotWindow(proc.MainWindowHandle); if (bmp == null) { // only give access to processes which provide a window continue; } // convert the resized picture to bytes byte[] picture = ImageHandler.ImageHandler.ImageToBytes(ImageHandler.ImageHandler.Resize(bmp, previewImageSize)); ProcessDescription desc = new ProcessDescription(picture, proc.Id, proc.ProcessName, proc.MainWindowTitle); processes.Processes.Add(desc); } return processes; }