sxper 2023-03-24 11:46 采纳率: 33.3%
浏览 28

delphi获取第三方进程里面的数据

想读取第三方软件里面stringgrid里面的刷新数据,最后一条。跑不通

img

delphi代码。gpt给的。报错。


procedure TForm1.Button1Click(Sender: TObject);


var
  hWebslin: HWND; // Webslin.exe main window handle
  hStringGrid: HWND; // StringGrid handle
  RowCount: Integer; // Number of rows
  ColCount: Integer; // Number of columns
  RowIndex: Integer; // Row index
  ColIndex: Integer; // Column index
  CellTextLength: Integer; // Cell text length
  CellTextBuffer: PChar; // Cell text buffer
  GM_GETROWCOUNT,GM_GETCOLCOUNT,GM_GETCELLTEXTLENGTH:integer;
  GM_GETCELLTEXT: PChar;


begin
  hWebslin := FindWindow(nil,'webslin.exe'); // Get webslin.exe main window handle by title (you can also use other methods such as EnumWindows or GetWindowThreadProcessId)

  if hWebslin <> 0 then // If webslin.exe main window handle is valid
  begin

    hStringGrid := FindWindowEx(hWebslin,0,nil,'Tstringgrid'); // Get StringGrid handle by class name (you can also use other criteria such as title or ID)

    if hStringGrid <> 0 then // If StringGrid handle is valid
    begin

      RowCount := SendMessage(hStringGrid, GM_GETROWCOUNT, 0, 0); // Get number of rows
      ColCount := SendMessage(hStringGrid, GM_GETCOLCOUNT, 0, 0); // Get number of columns

      RowIndex := RowCount -1 ; // Set row index to last row

      for ColIndex := 0 to ColCount -1 do // Loop through all columns in last row
      begin

        CellTextLength := SendMessage(hStringGrid,GM_GETCELLTEXTLENGTH ,RowIndex * ColCount + ColIndex +1 ,0); // Get cell text length by row and column index (note that index starts from one)
        GetMem(CellTextBuffer ,CellTextLength +1); // Allocate cell text buffer memory space (note that one extra byte is needed for null terminator)
        SendMessage(hStringGrid,GM_GETCELLTEXT ,RowIndex * ColCount + ColIndex +1 ,LPARAM(CellTextBuffer)); // Get cell text by row and column index and store it in buffer

        ShowMessage(CellTextBuffer); // Show cell text (you can also do other things with it)

        FreeMem(CellTextBuffer); // Free cell text buffer memory space

      end;

    end;

   end;
  • 写回答

3条回答 默认 最新

  • threenewbee 2023-03-24 12:02
    关注

    这些控件不是标准windows控件,所以spy++得不到数据,应该考虑直接去读取进程的内存获取。

    评论

报告相同问题?

问题事件

  • 创建了问题 3月24日

悬赏问题

  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答