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
}
}
Public Class EnumWin
Shared Sub Main()
For Each p As Process In Process.GetProcesses()
If Not p.MainWindowHandle.Equals(IntPtr.Zero)
Console.WriteLine(p.ProcessName _
& " : " & p.MainWindowTitle)
End If
Next
' 出力例:
' 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
End Sub
End Class