如果用findwindow必须知道标题所以你可以用Enumwindow先列出符合条件的窗口列<br>表:<br><br>function EnumWindowsProc(AHWnd: HWnd;<br> LPARAM: lParam): boolean; stdcall;<br>var<br> WndCaption: array[0..254] of char;<br> WndClassName: array[0..254] of char;<br>begin<br> GetWindowText(AHWnd, @WndCaption, 254);<br> GetClassName(AHWnd, @WndClassName, 254);<br> if (pos('Microsoft',wndcaption)<>0) then //用你已知的窗口标题替换这里<br> begin<br> with Form1.Memo1.Lines do<br> begin<br> Add(StrPas(WndCaption));<br> Add(StrPas(WndClassName));<br> add('HWND:'+inttostr(ahwnd)); //获得句柄<br> Add('-------');<br> end;<br> end;<br><br> Result := True;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> Memo1.Lines.Clear;<br> EnumWindows(@EnumWindowsProc, 0); //call back function 调用<br>end;<br><br>另外:<br>ahwnd:=findwindowEX(ahwnd,0,pchar('TButton'),pchar(buttoncaption));<br>找到button句柄,再sendmessage<br><br>