得到当前活动窗体的标题

 1 function  GetActiveWindowText: string;
2
3 var
4 hnd: HWND;
5
6 stlen: Integer;
7
8 begin
9
10 hnd := GetForegroundWindow;
11
12 stlen := GetWindowTextLength(hnd);
13
14 SetLength(Result, stlen);
15
16 GetWindowText(hnd, PChar(Result), stlen);
17
18 end;

  顺便一提,GetActiveWindow只能得到调用进程内的窗体Handle.

原文地址:https://www.cnblogs.com/solokey/p/2113338.html