-
:confused::confused::confused::confused::confused::confused:
Ok, Does anyone know how to close an application that is running (I suppose using API), by using the applications' pathname
for example: closing windows' explorer using the string,
c:\windows\explorer.exe
Understand???
(Is this possible??)
Any help would be greatly appreciated! :D
-
Here's one way. Just use the name of the window's caption as an argument in the FindWindow. It has to be exact.
Code:
Option Explicit
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 FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Const WM_CLOSE = &H10
Private Sub Command1_Click()
Dim rc As Long
rc = FindWindow(vbNullString, "Untitled - Notepad")
SendMessage rc, WM_CLOSE, 0, 0
End Sub
-
Already answered this in your other thread.
-
Ok Matt,
But when I put the code in, it didnt' work properly...
If I have the path in Text1, and I want to close the application relating to that path by pressing Command2, what would I do to manipulate the code for that....
(yes I'm an idiot :D:D:D)
-
Code:
Private Sub Command2_Click()
Call KillApp("" & Text1.Text & "")
End Sub