2011-11-23 47 views
0

我想盡量減少系統中運行的所有應用程序,除了我的。 我該怎麼做?如何最小化除我以外的所有應用程序?

我用這個代碼,但它僅適用於一些電腦:

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; 


德爾福XE /贏XP/Win 7的

+3

419感覺有點無證... –

+0

如果你延遲BringToFront甚至更多,說延遲(1500)? –

+0

如果您無法完全控制在該系統上安裝的內容,則無法可靠地執行此操作,也不應該這樣做。這與[我如何創建一個永遠不被其他頂級窗口覆蓋的最頂層窗口]非常相似(http://blogs.msdn.com/b/oldnewthing/archive/2011/03/10/10138969.aspx) –

回答

3

我並不是說這是一個好主意,但你可以嘗試用模擬贏+ M更換419

keybd_event(VK_LWIN, 0, 0, 0); 
keybd_event(ord('M'), 0, 0, 0); 
keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0); 
相關問題