PDA

Click to See Complete Forum and Search --> : Popup Killer


Apr 16th, 2000, 02:16 PM
Hi, I'm working on a program that kills popups from IE5
I use EnumWindows to find all the IE windows that are open, then I'm picking one window that is open, that I want to remain open, then closing the rest of the windows. This works all fine and dandy until I click on an application which opens it's own window. My program proceeds to close not only the new window but the one I want to remain open.
I used a MsgBox to see what program it is closing (used the handle to tell) and it shows that it's closing the right window but for some reason both windows close.

Here's how I'm closing the windows:

'Force the App to Shutdown
Public Sub ForceAppClosed(ByVal lHwnd As Long)

Dim lPID As Long
Dim lProcess
Dim lCode As Long

'Get the Windows ProcessID
Call GetWindowThreadProcessId(lHwnd, lPID)

'Get a Handle to the Process
lProcess = OpenProcess(PROCESS_ALL_ACCESS, 0&, lPID)

'Get the Processes Exit Code
Call GetExitCodeProcess(lPID, lCode)

'Tell the Process to Terminate
Call TerminateProcess(lProcess, '0&') 'IGNORE single quotes. used to fool the script so it doesn't place an icon.

End Sub