我自己解决了问题.但是又遇到了新的.下面这段代码在nt4上可以完全执行.但是在windows2000下抓取不到密码框内的内容<br>请高人看看看那里写错了<br>unit good;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> ExtCtrls, StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Timer1: TTimer;<br> Memo1: TMemo;<br> procedure Timer1Timer(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br> hEdit : THandle;<br>implementation<br><br>{$R *.DFM}<br> function EnumChildWindowsProc(hwnd: Integer; lparam: Longint): Boolean; stdcall;<br>//得到窗口(是一个MDIChild类型)中每个控件的 Text 内容(TEdit,TMaskEdit...),成功了。<br>var<br> buffer: array[0..255] of char;<br> s: string;<br>begin<br> Result := True;<br> GetClassName(hwnd, buffer, 256);<br> s := STRPAS(BUFFER);<br> if ((s <> 'TStaticText') and (s <> 'TGroupBox') and (s <> 'TPanel') and (s <> 'TStatusBar') and (s <> 'TButton')<br> and (s <> 'TBitBtn') and (s <> 'MDIClient') and (s <> 'TWjfDBGrid')) then<br> begin<br> SetLength(s, 256);<br> SendMessage(hwnd, WM_GETTEXT, 256, LongInt(S));<br> form1.memo1.Lines.Add(s);<br> end;<br>end;<br><br>procedure TForm1.Timer1Timer(Sender: TObject);<br>var<br> cursorpoint:TagPOINT;<br> windowhandle:hwnd;<br> textmaxlength:integer;<br> textcontent:array[0..100] of char;<br> returnlength:word;<br>begin<br> textmaxlength:=100;<br> Memo1.lines.clear;<br> if GetCursorPos(cursorpoint) then<br> begin<br> Memo1.Lines.Add(format('光标位置x=%d,y=%d',[cursorpoint.x,cursorpoint.y]));<br> windowhandle:=windowfrompoint(cursorpoint);<br> if windowhandle<>null then<br> Memo1.Lines.Add(format('光标处窗口名柄号为%d',[windowhandle]));<br> if iswindow(windowhandle) then<br> returnlength:=SendMessage(windowhandle,WM_GETTEXT,textmaxlength,lparam(@textcontent));<br> if returnlength>0 then<br> begin<br> Memo1.Lines.Add('读到窗口标题为:');<br> Memo1.Lines.Add(textcontent);<br> end;<br> EnumChildWindows(windowhandle, @EnumChildWindowsProc,0);<br> end;<br>end;<br><br><br><br>end.