试试这个:<br><br><br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, ExtCtrls, StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> NameLB: TLabel;<br> ClassLB: TLabel;<br> Timer1: TTimer;<br> Memo1: TMemo;<br> procedure Timer1Timer(Sender: TObject);<br> procedure FormCreate(Sender: TObject);<br> private<br> procedure GetMousePosHwndAndClassName(Sender : TPoint);<br> public<br> end;<br><br>var Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm1.Timer1Timer(Sender: TObject);<br>var rPos: TPoint;<br>begin<br> if boolean(GetCursorPos(rPos))<br> then GetMousePosHwndAndClassName(rPos);<br>end;<br><br>procedure TForm1.GetMousePosHwndAndClassName(Sender: TPoint);<br>var hWnd: THandle;<br> aName: array [0..255] of char;<br>begin<br> hWnd := WindowFromPoint(Sender);<br> NameLB.Caption := 'Handle:' + IntToStr(hWnd);<br><br> if boolean(GetClassName(hWnd, aName, 256)) then<br> begin<br> ClassLB.Caption := 'ClassName : ' + string(aName);<br> if Memo1.Lines[Memo1.Lines.Count-1]<>string(aName)<br> then Memo1.Lines.Add(string(aName));<br> end else ClassLB.Caption := 'ClassName : not found';<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> Form1.FormStyle := fsStayOnTop;<br> Timer1.Interval := 50;<br>end;<br><br>end.<br><br><br><br><br>