先找到你要查找的程序的句柄。然后用GetWindow列举其子窗的类名,如果该类名为
Edit,则那就是你要找的编辑控件句柄。
var
HWnd: THandle;
Str: PChar;
begin
GetMem(Str, 256);
try
Result := 0;
HWnd := GetWindow(SomeApplicationHandle, GW_CHILD);
repeat
GetClassName(HWnd, Str, 255);
if Str = 'Edit' then
ShowMessage(IntToHex(HWnd, 8));
HWnd := GetWindow(HWnd, GW_HWNDNEXT);
until HWnd = 0;
finally
FreeMem(Str, 256);
end;