获得密码框文本:
function lpEnumFunc(hwnd:integer;uint:integer):boolean;stdcall;
var hw,hs,wlong:integer;
sbuf,sb2:array[0..256] of char;
sb1:string;
begin
wlong:=GetWindowLong(hwnd,GWL_STYLE);
if (wlong and ES_PASSWORD)<>0 then
begin
inc(hcount);
hw:=GetWindowTextLength(hwnd);
sendmessage(hwnd,wm_gettext,40,integer(@sbuf));
strpcopy(sbuf,format('[Password %d] = %s',[hcount,sbuf]));
form1.listbox1.items.add(strpas(sbuf));
end;
result:=true;
end;
procedure TForm1.Button1Click(Sender: TObject);
var lp:integer;
begin
lp:=0;
hcount:=0;
form1.listbox1.items.clear;
//枚举子窗口,GetDesktopWindow用来得到桌面的句柄
EnumChildWindows(GetDesktopWindow,@lpEnumFunc,lp);
end;