// enumwin.cs using System; using System.Diagnostics; public class EnumWindows { static void Main() { foreach (Process p in Process.GetProcesses()) { if (p.MainWindowHandle != IntPtr.Zero) { Console.WriteLine(p.ProcessName + " : " + p.MainWindowTitle); } } // 出力例: // vim : VIM - C:\c#\tips\enumwin\enumwin.cs // explorer : C:\bin // NetCaptor : NetCaptor // OUTLOOK : 予定表 - Microsoft Outlook // cmd : コマンド プロンプト - enumwin // iexplore : @IT:Insider.NET - Microsoft Internet Explorer } } // コンパイル方法:csc enumwin.cs