var th1,th2,th3:Thandle;
 buffer:   Array[0..255]   of   Char;
begin
th1:=FindWindow(nil,'2.txt - 记事本');
th2:=GetDlgItem(th2,15)  ;
 SendMessage(th2,   WM_GETTEXT,   256,   integer(@buffer));
 memo1.Text:=buffer;
end;
我想得到 txt里面的内容如何得到??我这样写 新的memo中没有内容~

解决方案 »

  1.   

    th1:=FindWindow(nil,'2.txt - 记事本');
    th2:=GetDlgItem(th2,15) ;th2:=GetDlgItem(th1,15) ;吧
      

  2.   

    SendMessage(th1, WM_GETTEXT, 256, integer(@buffer));
      

  3.   

    为什么 棋牌的客户端 我用这个办法 没法得到想要的内容呢??
    var th1,th2,th3:Thandle;
           buffer:   Array[0..255]   of   Char;
    begin
    th1:=FindWindow(nil,'JJ德州扑克[1.0.3.18] -- 初级场(无限注) TN8501.40 总第3局');
    ///TKGameChatFrame
    th2:=FindWindowEx(th1,0,nil,'TKGameChatFrame');
    /////showmessage(inttostr(th2));
    th3:=GetDlgItem(th2,9000)  ;
     SendMessage(th3,   WM_GETTEXT,   256,   integer(@buffer));
    memo1.Text:=buffer;
    end;
    句柄都找对了 就是内容 获取不了 何解
      

  4.   

    参考
    这个是以前写的一个小工具。
    使用这个读取到记事本里的内容是没有问题的。
    是C++的,你看看,参考。LRESULT CALLBACK EnumChildProc(HWND hwnd, LPARAM)
    {
      char text[128], title[128];
      char Result[1024];
      GetClassName(hwnd,   text, 128);
      SendMessage(hwnd, WM_GETTEXT, (WPARAM)128, (LPARAM)title);
      memset(Result, 0, 1024);
      sprintf(Result, "%s\r%s\r%d", text, title, hwnd);
      AddDataToStringGrid(Result);
      return true; //true表示继续取,false表示不取
    }
      

  5.   

    /////觲w2@var   aa:array[1..10]of   byte;
    th1,th2,th3:Thandle;
    bb:integer;
    cc:pchar;
    begin
    th1:=FindWindow(nil,'JJ德州扑克[1.0.3.18] -- 初级场(无限注) TN8501.27 总第196局');
    ///TKGameChatFrame
    th2:=FindWindowEx(th1,0,nil,'TKGameChatFrame');
    /////showmessage(inttostr(th2));
    th3:=GetDlgItem(th2,9000)  ;
    cc:=@aa;
    bb:=10;
    sendmessage(th3,wm_gettext,bb,integer(@aa));
    memo1.text:=string(cc);
    end;我这样写的代码 可就读取出 乱码来 读取出来的内容是    觲w2@该怎么写代码
      

  6.   

    只要句柄对了 
    SendMessage(th2, WM_GETTEXT, 256, integer(@buffer));
    用这句就行 长度可以长大点
      

  7.   

    有些控件是非标准的,WM_GETTEXT获取不到内容
    有些控件做过特殊处理,不让你获取WM_GETTEXT内容,如密码