Hi all,
I'm looking to write some Visual Basic .NET code to find a Window given its Caption and then kill it entirely (not just minimise it).
I think I have found the correct Windows Handle using the following code (see eg below which uses just a new Notepad window), however I am struggling majorly trying to find the code to actually close the window. I can't even find code that will correctly return the PID of the window. Please help! ...
Module modMain
'API for picking up the Windows Handle of a Window
Private Declare Function FindWindow Lib "user32" Alias "FindWindow A" (ByVal ByVallpClassNam e As String, ByVal lpWindowName As String) As Integer
Public Sub Main()
Dim wHnd As Integer = GetWindowHandle ("Untitled - Notepad")
MsgBox("wHnd = " & wHnd)
End Sub
Private Function GetWindowHandle (ByVal strCaption As String) As Long
'Return the Windows Handle of the Window with Caption = strCaption
Return FindWindow(vbNu llString, strCaption)
End Function
End Module
I'm looking to write some Visual Basic .NET code to find a Window given its Caption and then kill it entirely (not just minimise it).
I think I have found the correct Windows Handle using the following code (see eg below which uses just a new Notepad window), however I am struggling majorly trying to find the code to actually close the window. I can't even find code that will correctly return the PID of the window. Please help! ...
Module modMain
'API for picking up the Windows Handle of a Window
Private Declare Function FindWindow Lib "user32" Alias "FindWindow A" (ByVal ByVallpClassNam e As String, ByVal lpWindowName As String) As Integer
Public Sub Main()
Dim wHnd As Integer = GetWindowHandle ("Untitled - Notepad")
MsgBox("wHnd = " & wHnd)
End Sub
Private Function GetWindowHandle (ByVal strCaption As String) As Long
'Return the Windows Handle of the Window with Caption = strCaption
Return FindWindow(vbNu llString, strCaption)
End Function
End Module
Comment