vaultworld
asked on
How do I only kill/close a child window without killing the Parent all in VB.NET
How do I only kill/close a child window without killing the Parent all in VB.NET
I'm trying it with:
'tempProc.Kill() 'Kills all Iexplorer open
'tempProc.CloseMainWindow( ) 'Prompts to closes
But maybe I need to be working with that specific handle?
Public Function EnumWindowsCallBack(ByVal hwnd As IntPtr, ByVal lParam As Int32) As Int32
Dim sSave As String
Dim ProcessID As Long
GetWindowThreadProcessId(h wnd, ProcessID)
Dim tempProc As Process = Process.GetProcessById(Pro cessID)
Dim processName As String = tempProc.ProcessName
If (processName = "iexplore") Then
'Get the windowtext length
sSave = Space(GetWindowTextLength( hwnd) + 1)
'get the window text
GetWindowText(hwnd, sSave, Len(sSave))
'remove the last Chr(0)
sSave = Microsoft.VisualBasic.Left (sSave, Len(sSave) - 1)
If (sSave.Length <> 0) Then
If sSave.ToString.IndexOf("Go ogle") >= 0 Then
sSave = "Found Google Search"
'tempProc.Kill() 'Kills all Iexplorer open
'tempProc.CloseMainWindow( ) 'Prompts to closes
End If
'Error below: Reference to a non-shared member requires an Object Reference
Lst.Items.Add(sSave)
'Lst.Items.Add(processName )
If sSave.Trim <> "" Then
Debug.WriteLine(sSave)
End If
End If
End If
Return 1 'continue enumeration
End Function
I'm trying it with:
'tempProc.Kill() 'Kills all Iexplorer open
'tempProc.CloseMainWindow(
But maybe I need to be working with that specific handle?
Public Function EnumWindowsCallBack(ByVal hwnd As IntPtr, ByVal lParam As Int32) As Int32
Dim sSave As String
Dim ProcessID As Long
GetWindowThreadProcessId(h
Dim tempProc As Process = Process.GetProcessById(Pro
Dim processName As String = tempProc.ProcessName
If (processName = "iexplore") Then
'Get the windowtext length
sSave = Space(GetWindowTextLength(
'get the window text
GetWindowText(hwnd, sSave, Len(sSave))
'remove the last Chr(0)
sSave = Microsoft.VisualBasic.Left
If (sSave.Length <> 0) Then
If sSave.ToString.IndexOf("Go
sSave = "Found Google Search"
'tempProc.Kill() 'Kills all Iexplorer open
'tempProc.CloseMainWindow(
End If
'Error below: Reference to a non-shared member requires an Object Reference
Lst.Items.Add(sSave)
'Lst.Items.Add(processName
If sSave.Trim <> "" Then
Debug.WriteLine(sSave)
End If
End If
End If
Return 1 'continue enumeration
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.