Option Explicit
Private Declare Function MessageBoxEx Lib "user32" Alias "MessageBoxExA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal uType As Long, ByVal wLanguageId As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function TerminateThread Lib "kernel32" (ByVal hThread As Long, ByVal dwExitCode As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function GetExitCodeThread Lib "kernel32" (ByVal hThread As Long, lpExitCode As Long) As Long
Private Declare Sub ExitThread Lib "kernel32" (ByVal dwExitCode As Long)
Private Sub Command1_Click()
'display asynch message box
MessageBoxEx 0&, "Pulchritude" & vbNewLine & "Ansync Messagebox", "Discombobulated", 0&, 0
End Sub
Private Sub Command2_Click()
'attempt to close asynch message box
Dim hwnd As Long
Dim Pid As Long
Dim TID As Long
Dim lpExitCode As Long
Dim hThread As Long
hwnd = FindWindow("#32770", "Discombobulated")
If hwnd Then
TID = GetWindowThreadProcessId(hwnd, Pid)
Call GetExitCodeThread(TID, lpExitCode)
'fine to here but now what?
End If
End Sub