0
votes

I have two processes A and B. Process A is a VCL forms application containing a form TMainForm. Process B is a DLL from which I want to remote-control this form. Something along the lines of (in process B):

MainForm := TMainForm.Create (nil);
MainForm.Handle := FindWindow ('TMainForm', 'MainForm Title');  // does not compile

// These two lines should remote-control the form in process A
MainForm.Edit1.Text := 'Test';
MainForm.Button1.Click;

Any ideas if and how this could be done?

1
That is not the point. I want to remote-control the application A from another application B and wanted to provide the "driver" for this in the form of a DLL.jpfollenius

1 Answers

3
votes

If you really have two separate processes, then you need inter-process communication (IPC). For example, you could make process A into an out-of-proc COM server which is consumed by process B in the manner of Office automation. That's one option of many, but they all require IPC.

However, it sounds a little like you have an executable and a DLL in the same process. In which case you have two separate instances of the VCL. Which means that you cannot pass a TForm object, or indeed any other VCL object between the two modules. In fact, you cannot pass any class between these two modules since you cannot share classes between modules. The TObject in module A is a different TObject from that in module B.

Your main options are:

  1. Use a package instead of a DLL.
  2. Use interfaces for your interop since these can be safely passed between two modules.