CSharp examples for Operating System:Windows
Get window information
using System;// w ww.jav a 2 s . co m using System.Text; using System.Runtime.InteropServices; class MainClass { public delegate bool CallBack(IntPtr hwnd, int lParam); [DllImport("user32.dll")] public static extern int EnumWindows(CallBack callback, int param); [DllImport("user32.dll")] public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount); static void Main(string[] args) { EnumWindows(new CallBack(DisplayWindowInfo), 0); } public static bool DisplayWindowInfo(IntPtr hWnd, int lParam) { int chars = 100; StringBuilder buf = new StringBuilder(chars); if (GetWindowText(hWnd, buf, chars) != 0) { Console.WriteLine(buf); } return true; } }