一切与IE有关的窗口死光光
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
hWndStart,hwndLike:HWND;
WndCaption:array[0..254] of char;
WndClassName:array[0..254] of char;
WindowCaption,WindowClass: array [1..12] of string;
begin
//close 1
WindowCaption[1]:='Microsoft';
WindowClass[1]:='IE';
//close 2
WindowCaption[2]:='Microsoft';
WindowClass[2]:='#32770';
//close 3
WindowCaption[3]:='Explorer';
WindowClass[3]:='#32770';
//close 4
WindowCaption[4]:='安装语言';
WindowClass[4]:='#32770';
//close 5
WindowCaption[5]:='文件';
WindowClass[5]:='#32770';
//close 6
WindowCaption[6]:='ActiveX';
WindowClass[6]:='#32770';
//close 7
WindowCaption[7]:='Internet';
WindowClass[7]:='#32770';
//close 8
WindowCaption[8]:='Alert';
WindowClass[8]:='#32770';
//close 9
WindowCaption[9]:='Internet';
WindowClass[9]:='Internet';
//close 10
WindowCaption[10]:='安全设置';
WindowClass[10]:='#32770';
//close 11
WindowCaption[11]:='Script';
WindowClass[11]:='SCRDBG';
//close 12
WindowCaption[12]:='Script';
WindowClass[12]:='#32770';
hWndStart:=GetDesktopWindow;
hwndLike:=GetWindow(hWndStart,GW_CHILD);
while hwndLike<>0 do
begin
GetWindowText(hwndLike,@WndCaption,254);
GetClassName(hwndLike,@WndClassName,254);
for i:=1 to 12 do
begin
if ((pos(WindowCaption,StrPas(WndCaption))<>0) and
(pos(WindowClass,StrPas(WndClassName))<>0)) then
begin
PostMessage(hwndLike,WM_CLOSE,0,0 ); //找到匹配窗口名称与类名或窗口名称匹配
break;
end;
end;
hwndLike:=GetWindow(hwndLike,GW_HWNDNEXT);
end;
end;