// 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.Runtime.InteropServices; public struct RECT { public int left; public int top; public int right; public int bottom; }; class MainClass { [DllImport("user32")] public static extern int FindWindow(string lpClassName, string lpWindowName); [DllImport("user32")] public static extern int GetWindowRect(int hwnd, ref RECT lpRect); public static void Main(string[] args) { int hwnd = FindWindow(null, "Untitled - Notepad"); RECT r = new RECT(); GetWindowRect(hwnd, ref r); Console.WriteLine((r.right - r.left) + " * " + (r.bottom - r.top)); } }