procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
hCurrentWindow: HWnd;
szText: array[0..254] of char;
hCurrentWindow := GetWindow(Handle, GW_HWNDFIRST);
i:=hCurrentWindow;
While hCurrentWindow <> 0 Do Begin
If GetWindowText(hCurrentWindow, @szText, 255) > 0 Then
begin
if pos('Microsoft Internet Explorer',Strpas(@szText))>0 then
postmessage(hCurrentWindow,WM_SYSCOMMAND,SC_CLOSE,0);
end;
hCurrentWindow := GetNextWindow(hCurrentWindow, GW_HWNDNEXT);
End;
end;