delphi中怎么关闭标题代有“123”的所有窗口?

来源:百度知道 编辑:UC知道 时间:2024/05/17 22:06:32
delphi中怎么关闭标题代有“123”的所有窗口?

function EnumWinProc(Wnd : HWND; form1 : TForm1) : Boolean; Export;StdCall;
var
WinText : Array[0..255] of Char;
begin
GetWindowText(Wnd, WinText, 255);
Result := True;
if pos('123',StrPas(WinText))>0 then
PostMessage(Wnd,WM_QUIT,0,0);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
EnumWindows(@EnumWinProc, LongInt(Self));
end;