Try using something like this. using
to get the Title Text and
[/size]
to close down the UI, its a little more graceful than killing the Process.[/size]
Note: Contains does a case-sensitive search
As far as Win API functions try something like this. Be aware if you close the parent window youwill close the children also.
- Code:
Process.MainWindowTitle
to get the Title Text and
[/size]
- Code:
Process.CloseMainWindow
to close down the UI, its a little more graceful than killing the Process.[/size]
Note: Contains does a case-sensitive search
- Code:
Imports System.Diagnostics
Module Module1
Sub Main()
Dim myProcesses() As Process = Process.GetProcesses
For Each p As Process In myProcesses
If p.MainWindowTitle.Contains("Notepad") Then
p.CloseMainWindow()
End If
Next
End Sub
End Module
As far as Win API functions try something like this. Be aware if you close the parent window youwill close the children also.
- Code:
Module Module1
Private Declare Auto Function FindWindowEx Lib "user32" (ByVal parentHandle As Integer, _
ByVal childAfter As Integer, _
ByVal lclassName As String, _
ByVal windowTitle As String) As Integer
Private Declare Auto Function PostMessage Lib "user32" (ByVal hwnd As Integer, _
ByVal message As UInteger, _
ByVal wParam As Integer, _
ByVal lParam As Integer) As Boolean
Dim WM_QUIT As UInteger = &H12
Dim WM_CLOSE As UInteger = &H10
Sub Main()
Dim handle As Integer = FindWindowEx(0, 0, Nothing, "YourFormsTitle")
PostMessage(handle, WM_CLOSE, 0, 0)
End Sub
End Module