-
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
-
Thanks!
Thank you both, I´ll paste the code and try it right now!
-
An easier way of doing it since you call up a DOS application:
Code:
Call Shell(Environ("ComSpec") & " /c pkunzip myfile.zip", vbHide)
This will open a command prompt run the pkunzip application and close after it's done.
Good luck!
-
Thank you
It works smoothly. I only notice a small "flash" when DOS window opens, but it´s OK.
Obrigado!