<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      DELPHI 隱藏程序窗口,以及TListView控件,點擊標題進行排序

      設置視圖:

       運行效果:

       

       

       

       

      unit HideWindown;
      
      interface
      
      uses
        Windows, Messages, SysUtils, Classes, Forms, StdCtrls, ActiveX, ComObj, ShellAPI, Tlhelp32,
        Vcl.Controls, Vcl.ComCtrls, psapi, Vcl.ExtCtrls;
      
      type
        TForm1 = class(TForm)
          GetWList: TButton;
          ListView1: TListView;
          HideBtn: TButton;
          ShowBtn: TButton;
          RadioGroup1: TRadioGroup;
          Edit1: TEdit;
          QueryBtn: TButton;
          procedure GetWListClick(Sender: TObject);
          procedure FormCreate(Sender: TObject);
          procedure HideBtnClick(Sender: TObject);
          procedure ShowBtnClick(Sender: TObject);
          procedure RadioGroup1Click(Sender: TObject);
          procedure QueryBtnClick(Sender: TObject);
          procedure Edit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
          procedure ListView1ColumnClick(Sender: TObject; Column: TListColumn);
      
        private
          procedure SetWindowState(isVisible: Boolean);
          procedure AddListItem(hwnd: HWND; State, Title: string);
          function FoundTitle(beginIndex, endIndex: Integer): Boolean;
          var
            public
          { Public declarations }
        end;
      
      var
        Form1: TForm1;
        FSortColumn: Integer;      //當前哪一列正在被排序
        FSortAscending: Boolean;  //排序的狀態
      
      implementation
      
      {$R *.dfm}
      
      function GetWindowTitle(hwnd: hwnd): string;
      var
        Buffer: array[0..255] of Char;
      begin
        Result := '';
        if GetWindowText(hwnd, Buffer, SizeOf(Buffer)) > 0 then
        begin
          Result := Buffer;
        end;
      end;
      
      procedure EnumWindowsProc(hwnd: hwnd; lParam: lParam); stdcall;
      const
        MAX_PATH = 260; // 確保常量定義明確
      var
        ProcessID: DWORD;
        ProcessHandle: THandle;
        Title: array[0..MAX_PATH] of Char;
        ListItem: TListItem;
        State: string;
        ShouldAdd: Boolean;
      begin
        // 獲取進程 ID 和窗口標題
        GetWindowThreadProcessId(hwnd, @ProcessID);
        GetWindowText(hwnd, Title, MAX_PATH);
      
        // 如果窗口標題不為空
        if Title <> '' then
        begin
          // 打開進程以獲取更多信息
          ProcessHandle := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ, False, ProcessID);
          if ProcessHandle <> 0 then
          try
            // 檢查窗口是否可見
            ShouldAdd := IsWindowVisible(hwnd);
            if ShouldAdd then
              State := '顯示'
            else
              State := '隱藏';
      
            // 根據 RadioGroup 的選擇決定是否添加項
            case Form1.RadioGroup1.ItemIndex of
              0: // 顯示所有窗口
                ShouldAdd := True;
              1: // 只顯示可見窗口
                ShouldAdd := ShouldAdd;
              2: // 只顯示隱藏窗口
                ShouldAdd := not ShouldAdd;
            else
              ShouldAdd := False;
            end;
      
            // 如果符合條件,添加到 ListView
            if ShouldAdd then
            begin
              Form1.AddListItem(hwnd, State, Title);
            end;
      
          finally
            CloseHandle(ProcessHandle);
          end;
        end;
      end;
      
      procedure TForm1.AddListItem(hwnd: hwnd; State, Title: string);
      var
        ListItem: TListItem;
      begin
        ListItem := Form1.ListView1.Items.Add;
        ListItem.Caption := IntToStr(hwnd);
        ListItem.SubItems.Add(State);
        ListItem.SubItems.Add(Title);
      end;
      
      procedure TForm1.GetWListClick(Sender: TObject);
      begin
        ListView1.Clear;
        ListView1.Items.BeginUpdate;
        try
          EnumWindows(@EnumWindowsProc, 0);
        finally
          ListView1.Items.EndUpdate;
        end;
      end;
      
      procedure TForm1.SetWindowState(isVisible: Boolean);
      begin
        var n := ListView1.Items.Count;
        if (n = 0) or (ListView1.ItemIndex = -1) then
        begin
          Application.MessageBox('請先選中一個目標', '錯誤!', MB_OK + MB_ICONSTOP);
          exit;
        end;
      
        // 遍歷Listview1中的所有選中項
        for var i := 0 to ListView1.Items.Count - 1 do
        begin
          var selectedItem := ListView1.items[i];
          if selectedItem.Selected then
          begin
            if isVisible then
            begin
              selectedItem.SubItems[0] := '顯示';
              ShowWindow(StrToInt64(selectedItem.Caption), SW_SHOW);
            end
            else
            begin
              selectedItem.SubItems[0] := '隱藏';
              ShowWindow(StrToInt64(selectedItem.Caption), SW_HIDE);
            end;
            Break;
      
          end;
        end;
      
      end;
      
      procedure TForm1.ShowBtnClick(Sender: TObject);
      begin
        SetWindowState(TRUE);   //顯示應用
      end;
      
      procedure TForm1.HideBtnClick(Sender: TObject); //隱藏應用
      begin
        SetWindowState(False);
      end;
      
      function CustomSortProc(Item1, Item2: TListItem; ColumnIndex: integer): integer; stdcall;
      begin
        if FSortAscending then
        begin
          if ColumnIndex = 0 then
            Result := CompareText(Item1.Caption, Item2.Caption)
          else
            Result := CompareText(Item1.SubItems[ColumnIndex - 1], Item2.SubItems[ColumnIndex - 1]);
        end
        else
        begin
          if ColumnIndex = 0 then
            Result := CompareText(Item2.Caption, Item1.Caption)
          else
            Result := CompareText(Item2.SubItems[ColumnIndex - 1], Item1.SubItems[ColumnIndex - 1]);
        end;
      end;
      
      procedure TForm1.ListView1ColumnClick(Sender: TObject; Column: TListColumn);
      begin
        if Column.Index = FSortColumn then
          FSortAscending := not FSortAscending
        else
        begin
          FSortColumn := Column.Index;
          FSortAscending := True;
        end;
        ListView1.CustomSort(@CustomSortProc, FSortColumn);
      end;
      
      function TForm1.FoundTitle(beginIndex, endIndex: Integer): Boolean;
      begin
        for var I := beginIndex to endIndex do
        begin
          // 檢查當前項的標題或子項是否包含Edit1.Text
          if ansiPos(LowerCase(Edit1.Text), LowerCase(ListView1.Items[I].SubItems[1])) > 0 then
          begin
            Result := True;
            ListView1.Items[I].Selected := True;
            ListView1.Items[I].MakeVisible(False);
            Break;
          end
          else
          begin
            ListView1.Items[I].Selected := False;
          end;
        end;
      end;
      
      procedure TForm1.QueryBtnClick(Sender: TObject);
      var
        I, indx: Integer;
        Found: Boolean;
      label
        tip;
      begin
        indx := ListView1.ItemIndex;
        if indx = -1 then
          indx := 0
        else if indx <> ListView1.Items.Count - 1 then
          indx := indx + 1;
      
        // 遍歷ListView中的所有項
        Found := FoundTitle(indx, ListView1.Items.Count - 1);
        if not Found then
        begin
          if indx <> 0 then
          begin
            Found := FoundTitle(0, indx - 1);
            if not Found then
              goto tip
            else
              exit;
          end;
      tip:
          Application.MessageBox('我翻到底了,但是沒找到匹配的項.', '錯誤!', MB_OK + MB_ICONSTOP);
        end;
      end;
      
      procedure TForm1.RadioGroup1Click(Sender: TObject);
      begin
        GetWListClick(Sender);
      end;
      
      procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
      begin
        if Key = VK_RETURN then
          QueryBtnClick(Sender);      //按下回車,執行查詢
      end;
      
      procedure TForm1.FormCreate(Sender: TObject);
      begin
      
        ListView1.ViewStyle := vsReport;      //設置視圖模式
        ListView1.Columns.Add.Caption := '窗口句柄';
        ListView1.Columns.Add.Caption := '顯示狀態';
        ListView1.Columns.Add.Caption := '應用程序名稱';
        //設置列寬.-1表示匹配最長內容,-2表示匹配標題長度
        ListView1.Columns[0].Width := -2;
        ListView1.Columns[1].Width := -2;
        ListView1.Columns[2].Width := -2;
        GetWListClick(Sender);
        FSortColumn := 0;
        FSortAscending := true;
      end;
      
      end.

       

      posted @ 2024-10-20 11:36  一曲輕揚  閱讀(335)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 国产亚洲精品AA片在线播放天| 综合偷自拍亚洲乱中文字幕| 国产精品美女www爽爽爽视频| 九九热免费在线播放视频| 国产成人午夜福利在线观看| 人妻丝袜中文无码av影音先锋| 衡阳市| 四虎国产精品久久免费地址| 亚洲av成人无码精品电影在线| 人妻av无码一区二区三区| 免费人成在线观看网站| 亚洲国产亚洲国产路线久久| 国产地址二永久伊甸园| 国产无遮挡又黄又爽不要vip软件| 国产精品老熟女露脸视频| 天天躁夜夜躁狠狠喷水| 人妻中文字幕不卡精品| 大肉大捧一进一出好爽视频mba| 欧美黑人性暴力猛交在线视频| 亚洲精品日韩在线丰满| 国产在线精品一区二区三区不卡| 精品无码成人片一区二区| 亚洲第一无码AV无码专区| 男女性高爱潮免费网站| 中文字幕亚洲综合小综合| 午夜国产精品福利一二| 亚洲国产性夜夜综合| 国产av熟女一区二区三区| 潘金莲高清dvd碟片| 亚洲sm另类一区二区三区| 亚洲老熟女一区二区三区| 又爽又黄无遮挡高潮视频网站| 欧美丰满熟妇性xxxx| 亚洲综合精品第一页| 国产精品熟妇视频国产偷人| 亚洲精品三区四区成人少| 亚洲综合成人av在线| 欧美丰满熟妇xxxx性| 人妻精品久久无码区| 国产永久免费高清在线观看| 国产中文字幕在线一区|