Windows - fechando todas as janelas do explorer

Top  Previous  Next

function EnumWindowsProc(Wnd: HWnd; Param: LParam): bool; stdcall;

var

 TextBuffer: array[0..255of Char;

begin

  GetClassName(Wnd,TextBuffer,255);

  if String(TextBuffer) = 'CabinetWClass' then

    SendMessage(Wnd,WM_SYSCOMMAND,SC_CLOSE,0);

  Result := true;

end;

 

procedure TForm1.Button1Click(Sender: TObject);

begin

  EnumWindows(@EnumWindowsProc, 0);

end;