FECHAR PROGRAMA EXTERNO
Pessoal, é possÃvel encerrar uma aplicação externa (criada por mim), ao clicar, por exemplo, em um CommandButton?
Obrigado.
Gewton Jhames
Obrigado.
Gewton Jhames
Tente o seguinte:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_CLOSE = &H10
Private Sub Command1_Click()
Dim WinWnd As Long
WinWnd = FindWindow(vbNullString, "Caption da Aplicação que quer fechar")
If WinWnd <> 0 Then
PostMessage WinWnd, WM_CLOSE, 0&, 0&
Else
MsgBox "Essa aplicação não se encontra aberta"
End If
End Sub
Tópico encerrado , respostas não são mais permitidas