A、B是运行中的程序,
如何在B程序中获取A程序中的某些内容(如StringGrid中)
A程序中没有任何接口
AB均为Delphi所编
------------------
StringGrid 的句柄我取得了,现在该如何取得 StringGrid 中的所有内容

解决方案 »

  1.   

    用消息An application sends a WM_GETTEXT message to copy the text that corresponds to a window into a buffer provided by the caller. WM_GETTEXT  
    wParam = (WPARAM) cchTextMax;   // number of characters to copy 
    lParam = (LPARAM) lpszText;     // address of buffer for text 
     ParameterscchTextMaxValue of wParam. Specifies the maximum number of characters to be copied, including the terminating null character. lpszTextValue of lParam. Points to the buffer that is to receive the text.  Return ValuesThe return value is the number of characters copied. Default ActionThe DefWindowProc function copies the text associated with the window into the specified buffer and returns the number of characters copied. ResFor an edit control, the text to be copied is the content of the edit control. For a combo box, the text is the content of the edit control (or static-text) portion of the combo box. For a button, the text is the button name. For other windows, the text is the window title. To copy the text of an item in a list box, an application can use the LB_GETTEXT message. 
    When the WM_GETTEXT message is sent to a static control with the SS_ICON style, the handle of the icon will be returned in the first four bytes of the buffer pointed to by lpszText. This is true only if the WM_SETTEXT message has been used to set the icon. In a rich edit control, if the text to be copied exceeds 64K, use either the message EM_STREAMOUT or EM_GETSELTEXT.
      

  2.   

    用回调函数,EnumWindowsProc和EnumChildProc
      

  3.   

    http://www.delphibbs.com/delphibbs/dispq.asp?LID=2221598
      

  4.   

    var
    H1,H2,H3:THandle ;
    begin
      H1:=FindWindow(nil,'B程序的caption);   //StringGrid所在窗体的caption
      
      H2 := Findwindowex(H1,0,'TEdit',nil); //得到class为TEdit的第一个控件的句柄.
    //H2 := Findwindowex(H1,0,'TEdit','Edit1'); //如果知道name为Edit1,就可以这样写.
      Sendmessage(h2,WM_GETTEXT,255,p) ; //p为你想要的文本,size为文本长度
      showmessage(string(p)) ;
      

  5.   

    >>>>>>>>to letgolxh(夕阳倦鸟) WM_GETTEXT 没用,现在面对的是StringGrid