Option Explicit
Public Declare Function GetDesktopWindow Lib "user32" () As Long
Public Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Public Declare Function FindWindowEx Lib "user32" _
Alias "FindWindowExA" (ByVal hWnd1 As Long, _
ByVal hWnd2 As Long, _
ByVal lpsz1 As String, _
ByVal lpsz2 As String _
) As Long
Public Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, _
ByRef lpdwProcessId As Long _
) As Long
Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, _
ByVal nCmdShow As Long _
) As Long
Public Const SW_MAXIMIZE = &H3
Function FindThisWindow(ByRef hwnd As Long, _
Optional ByVal WindowCaption As String, _
Optional ByVal WinClass As String _
) As Boolean
Dim _
hwndDeskTop As Long, _
lCurrProc As Long, _
lWinProc As Long
lCurrProc = GetCurrentProcessId()
hwndDeskTop = GetDesktopWindow()
Do
hwnd = FindWindowEx(hwndDeskTop, hwnd, WinClass, WindowCaption)
Call GetWindowThreadProcessId(hwnd, lWinProc)
Loop Until lWinProc = lCurrProc Or hwnd = 0
FindThisWindow = Not hwnd = 0
End Function