//声明:WindowFromPoint(Point: TPoint): HWND;
//举例:unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls, ExtCtrls;typeTForm1 = class(TForm)Button1: TButton;Timer1: TTimer;procedure Timer1Timer(Sender: TObject);end;varForm1: TForm1;implementation{$R *.dfm}varh: HWND;procedure TForm1.Timer1Timer(Sender: TObject);varpt: TPoint;arr: array[0..254] of Char;beginif GetCursorPos(pt) then {如果能获取点}beginh := WindowFromPoint(pt); {返回句柄}GetClassName(h, arr, Length(arr)); {获取该句柄窗口的类名}Text := arr; {显示在标题}end;end;end.
//效果图:
联系客服