我希望尽量减少系统中运行的所有应用程序,除了我的。 我怎样才能做到这一点?
我使用了此代码,但它仅适用于某些计算机:
procedure MinAllWnd_ByShell;
VAR IntHwnd: Integer;
begin
IntHwnd:= FindWindow('Shell_TrayWnd', nil);
PostMessage(IntHwnd, WM_COMMAND, 419, 0);
end;
然后
procedure TFrmMain.btnMinimizeAll_Click(Sender: TObject);
begin
{ Send MINIMIZE message }
MinAllWnd_ByShell; { This sends a message to Windows. Windows sends the minimize signal back to us after a delay }
Delay(150); { We wait few miliseconds to receive the message in our message queue }
Application.ProcessMessages; { By now we should have received the message so we process the queue. }
{ Now self restore }
BringToFront;
ShowWindow(frmMain.Handle, SW_RESTORE);
end;
Delphi XE / Win XP / Win 7
答案 0 :(得分:3)
我不是说这是一个好主意,但您可以尝试用模拟的Win + M替换419
:
keybd_event(VK_LWIN, 0, 0, 0);
keybd_event(ord('M'), 0, 0, 0);
keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0);