var<br> Hwnd: THandle;<br> S: string;<br> Count, I: Integer;<br>begin<br> //假设另一个程序的窗口的类名是TForm1,ListBox的类名是TListBox,这里自己做相应修改<br> Hwnd := FindWindowEx(FindWindow('TForm1',nil),0,'TListBox',nil);<br> if Hwnd = 0 then ShowMessage('not found!');<br><br> Count := SendMessage(Hwnd, LB_GETCOUNT, 0, 0);<br> for I := 0 to Count - 1 do<br> begin<br> SetLength(S, 255);<br> SetLength(S, SendMessage(Hwnd, LB_GETTEXT, I, Integer(Pointer(S))));<br> Memo1.Lines.Add(s);<br> end;<br>end;