It's always a good idea to use DestroyWindow to free up any resources. Also, since Winoldap is the name, it should be in the second parameter of FindWindow.
Code:Private 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 Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long Private Const WM_CLOSE = &H10 Private Sub Command1_Click() Dim hApp As Long hApp = FindWindowEx(0&, 0&, vbNullString, "Winoldap") If hApp <> 0 Then SendMessage hApp, WM_CLOSE, 0, 0 DestroyWindow hApp End If End Sub




Reply With Quote