' 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) 
Imports System
Imports System.Diagnostics
Imports System.Runtime.InteropServices

Namespace E
    Public Class Program
        Public Structure RECT
            Public Left As Integer
            Public Top As Integer
            Public Right As Integer
            Public Bottom As Integer
        End Structure
        <DllImport("user32.dll")> _
        Private Shared Function GetClientRect(ByVal hWnd As IntPtr, ByRef lpRect As RECT) As Boolean
        End Function
        Public Shared Sub Main(ByVal args As String())
            Dim ps As Process() = Process.GetProcesses()
            For Each p As Process In ps
                Console.Write(p.ProcessName + " : ")
                If p.MainWindowHandle = IntPtr.Zero Then
                    Console.WriteLine("Non GUI")
                Else
                    Dim r As RECT
                    GetClientRect(p.MainWindowHandle, r)
                    Console.WriteLine((r].Right - r].Left) + " x " + (r.Bottom - r.Top))
                End If
            Next
        End Sub
    End Class
End Namespace
