1

Heading : How can I read a StringGrid content in another application's window?

I could get the StringGrid's handle

moskito-x
  • 11,832
  • 5
  • 47
  • 60
Emre Duman
  • 13
  • 3
  • 1
    String grid is not a Windows control, so forget about Windows messaging. – TLama Jul 15 '14 at 09:49
  • Do you have access to the source code for both applications? Do you know for certain it's a string grid or even that the other application is written in Delphi? – Andy_D Jul 15 '14 at 10:05
  • I don't have access to the source code for other applications. But, other application is written in Delphi 5.0, I know for certain – Emre Duman Jul 15 '14 at 10:16

1 Answers1

1

A Delphi string grid is a pure VCL control. You cannot use windows messages to read its content. You cannot use any of the automation APIs because Embarcadero do not and have never made their controls accessible. For which, incidentally, shame on them.

The only viable way to do this is through gross hacking. If you know the memory layout of the control you can read its memory the same way as a debugger does. Using calls to ReadProcessMemory. However, this will be exceptionally messy and hard to achieve.

A simple approach would be to inject a DLL into the target process. So long as your DLL is built with the same version of Delphi as the target process, there's a reasonable chance that you'll be able to read out the contents of the grid. You can then use IPC to send the information back to the other program.

Note that none of these solutions are remotely appealing. If you can find a cleaner way to do this, possibly avoiding this target process altogether, then you should give it strong consideration.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490