2011-11-23 46 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); 
相关问题