用回调技术及EnumWindows()函数来枚举所有的活动窗体,给你个思路:<br><br>function EnumWindowsProc(hWindow:hWnd; lParam:LongInt):Bool {$IFDEF Win32}stdcall;{$ELSE};export;{$ENDIF}<br>var<br> lpBuffer: PChar;<br> WindowCaptionFound: bool;<br> ClassNameFound: bool;<br>begin<br> GetMem(lpBuffer, 255);<br> Result := true;<br> WindowCaptionFound := false;<br> ClassNameFound := false;<br> try<br> //getwindowText复制指定窗体的标题或内容至buffer中<br> if GetWindowText(hWindow,lpBuffer, 255) > 0 then<br> //判断是否为自己要查找的窗体<br> if Pos(PFindWindowStruct(lParam).caption, StrPas(lpBuffer)) > 0 then<br> WindowCaptionFound := true;<br> if PFindWindowStruct(lParam).ClassName = '' then<br> ClassNameFound := true<br> else<br> //将指定窗体的类名复制至buffer中<br> if GetClassName(hWindow, lpBuffer, 255) > 0 then<br> if Pos(PFindWindowStruct(lParam).ClassName, StrPas(lpBuffer))>0 then<br> ClassNameFound := true;<br> //如果已经全部找到,则告诉调用函数停止枚举<br> if (WindowCaptionFound and ClassNameFound) then<br> begin<br> PFindWindowStruct(lParam).WindowHandle := hWindow;<br> result := false;<br> end;<br> finally<br> //释放所开辟的空间<br> FreeMem(lpBuffer, sizeof(lpBuffer^));<br> end;<br>end;<br><br>function FindAWindow(Caption: string; ClassName: string): THandle;<br>var<br> WindowInfo:TFindWindowStruct;<br>begin<br> //根据要查找的标题或类名给WindowInfo赋值<br> WindowInfo.Caption := Caption;<br> WindowInfo.ClassName := ClassName;<br> WindowInfo.WindowHandle := 0;<br> //开始枚举所有活动窗体,查找符合条件的<br> EnumWindows(@EnumWindowsProc, LongInt(@WindowInfo));<br> //返回要查找的窗体句柄<br> {FindAWindow}result := WindowInfo.WindowHandle;<br>end;<br><br>procedure TFormMain.Button2Click(Sender: TObject);<br>var<br> TheWindowHandle:THandle;<br> StartupInfo: TSTARTUPINFO;<br> ProcessInfo: TPROCESSINFORMATION;<br>begin<br> TheWindowHandle:=findwindow('浏览','');<br> if TheWindowHandle<>0 then<br> begin<br> ListBox.Add..............<br> end<br>end;