Wolfgang Chien's Homepage | Delphi學習筆記 - 問答篇 |
如果我想要取得Windows環境下的一些資訊, 如現在有幾個視窗正開啟著, 又各個正在執行的Applications 的名稱為何等等....我要如何做到呢?
謹舉出一個例子提供您參考:
大綱是以 GetWindow() 配合 GetWindowText() 逐一查出各視窗的標題
![]() |
1. File | New Project 開始一個新的專案 |
![]() |
2. 在 Form1 中安排 Button 與 Memo 各一 |
![]() |
3. 在 Button1 的 OnClick 事件中撰寫程式如下:
procedure TForm1.Button1Click(Sender: TObject); var hCurrentWindow: HWnd; szText: array[0..254] of char; begin hCurrentWindow := GetWindow(Handle, GW_HWNDFIRST); while hCurrentWindow <> 0 do begin if GetWindowText(hCurrentWindow, @szText, 255) > 0 then Memo1.Lines.Add(StrPas(@szText)); hCurrentWindow := GetWindow(hCurrentWindow, GW_HWNDNEXT); end; end; |
.
首頁 | 學習筆記 | 主題公園 | 軟體下載 | 關於本站 | 討論信群 | 相約下次 |