方法如下:
procedure checkerror; {查找错误窗口进行关闭或者隐藏}
var
h:hwnd; //错误窗口句柄
p,name,ps:array[0..254] of Char;//用来存放制定进程的classname的数组
begin
{***方法是便利所有窗口,查找相同标题窗口,找到后再判断类是否相同,相同隐藏***}
h := GetWindow(Handle, GW_HWNDFIRST);
while h <> 0 do
begin
GetWindowText(h, @name, Length(name));
if name=ErrorCaption then
begin
GetClassName(h, ps, 255);
if ps<>'classname' then ShowWindow(h,SW_HIDE);
end;
h := GetWindow(h, GW_HWNDNEXT);
end;
Sleep(1500);
end;