var<br>hcrrentwindow:hwnd;<br>sztext:array[0..254] of char;<br>s:string;<br>begin<br>hcrrentwindow:=GetWindow(handle,GW_HWNDFIRST);<br>while hcrrentwindow<>0 do<br>begin<br>if GetWindowtext(hcrrentwindow,@sztext,255)>0 then<br>begin<br>s:=strpas(@sztext);<br>if pos('Microsoft Excel',s)<>0 then//如果发现含有Microsoft Excel的窗口将其关闭。<br>SendMessage(hcrrentwindow,WM_CLOSE,0,0);<br>Memo1.Lines.Add(s);<br>end;<br>hcrrentwindow:=GetWindow(hcrrentwindow,GW_HWNDNEXT);<br>end;<br>end;