delphi中最小化其他程序及所有程序窗口最小化


本文整理自网络,侵删。

 
1.所有程序最小化


uses ComObj;

var
   shell : OleVariant;
begin
   shell := CreateOleObject('Shell.Application');
  shell.minimizeAll;
end;
2.最小化其他程序
 spy++ 查找要最小化的程序classname
var  
  Indicador :Integer;
begin 
  // Find the window by Classname
  Indicador := FindWindow(PChar('notepad'), nil);
  // if finded
  if (Indicador <> 0) then begin
    // Minimize
    ShowWindow(Indicador,SW_MINIMIZE);
  end;
end;

3.根据程序标题最小化程序
  
function FindWindowByTitle(WindowTitle: string): Hwnd;
    var
      NextHandle: Hwnd;
      NextTitle: array[0..260] of char;
begin
      // Get the first window
      NextHandle := GetWindow(Application.Handle, GW_HWNDFIRST);
      while NextHandle > 0 do
      begin
        // retrieve its text
        GetWindowText(NextHandle, NextTitle, 255);
        if Pos(WindowTitle, StrPas(NextTitle)) <> 0 then
        begin
          Result := NextHandle;
          Exit;
        end
        else
          // Get the next window
          NextHandle := GetWindow(NextHandle, GW_HWNDNEXT);
      end;
      Result := 0;
end;

procedure hideExWindow()
var Indicador:Hwnd;
begin
    // Find the window by Classname
    Indicador := FindWindowByTitle('MyApp'); 
    // if finded
    if (Indicador <> 0) then
    begin
        // Minimize
        ShowWindow(Indicador,SW_HIDE); //SW_MINIMIZE
    end;
end;

相关阅读 >>

Delphi x 的 y 次方

Delphi inttostr 将“整数型”转换成“字符型”

pos、ansipos、fillchar在Delphi2010中unicode的问题

Delphi cxgrid中回车键光标移到下列

Delphi 字符串加密解密单元

Delphi xe3里判断网络是否连接成功

Delphi 测试磁盘是否具有写访问权限

Delphi 检测鼠标键盘多久没有活动

Delphi 各种tstream(流)介绍

Delphi android 按包名判断是否安装了app

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...