试一试我的代码? 我试过,可以的。别忘给分哦
function EnumChildWindowsProc(hwnd: Integer; lparam: Longint): Boolean; stdcall;
var
buffer: array[0..255] of char;
begin
Result := True;
GetClassName(hwnd,buffer,256);
if StrPas(Buffer)='Edit' then
begin
PInteger(lparam)^ := hwnd;
Result:=False;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
hwnd: Integer;
buffer: array[0..255] of char;
begin
hwnd := FindWindow('CabinetWClass',nil);
if hwnd<>0 then
begin
EnumChildWindows(hwnd,@EnumChildWindowsProc,Integer(@hwnd));
StrPCopy(buffer,Edit1.Text);
SendMessage(hwnd,WM_SETTEXT,0,Integer(@buffer[0]));
end;
end;