// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Diagnostics; using System.Runtime.InteropServices; namespace E { public class Program { public struct RECT { public int Left; public int Top; public int Right; public int Bottom; } [DllImport("user32.dll")] static extern bool GetClientRect(IntPtr hWnd, out RECT lpRect); public static void Main(string[] args) { Process[] ps = Process.GetProcesses(); foreach(Process p in ps) { Console.Write(p.ProcessName + " : "); if(p.MainWindowHandle == IntPtr.Zero) { Console.WriteLine("Non GUI"); } else { RECT dim; GetClientRect(p.MainWindowHandle, out dim); Console.WriteLine((dim.Right - dim.Left) + " x " + (dim.Bottom - dim.Top)); } } } } }