Recent

Author Topic: InterProcessCommunication to a Delphi7 app from 64 bit Windows app?  (Read 4065 times)

BosseB

  • Sr. Member
  • ****
  • Posts: 468
I need to implement specific hardware functionality using Delphi7 because of interfacing issues for the hardware access that cannot be implemented with FreePascal.
So I was thinking of building an IPC comm channel, but how can that be done between a 64 bit Lazarus/Fpc app and a Delphi7 32 bit "server"?

I found this example on another thread here which discusses IPC comm.
However this implements both sides using Lazarus/Fpc for both server and client...
How can I build the Delphi7 server such that it can serve the Lazarus client?

I have not done something like this  previously and I do not want to bring up  TCP/IP comm or the like. The Delphi7 app shall implement a small number of commands for which it will return a response when called. That is all.

Calls can come from one or several FreePascal applications and they typically only do this very sparingly with hours in between (but always when they start up).

Any ideas/suggestions?
--
Bo Berglund
Sweden

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: InterProcessCommunication to a Delphi7 app from 64 bit Windows app?
« Reply #1 on: March 29, 2023, 11:53:39 pm »
what specifics are stopping you to use FPC/Laz ?
The only true wisdom is knowing you know nothing

Zvoni

  • Hero Member
  • *****
  • Posts: 2319
Re: InterProcessCommunication to a Delphi7 app from 64 bit Windows app?
« Reply #2 on: March 30, 2023, 12:01:52 am »
Adding to jamie: IPC between 32-bit and 64-bit your best bet usually is Sockets
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: InterProcessCommunication to a Delphi7 app from 64 bit Windows app?
« Reply #3 on: March 30, 2023, 12:26:18 am »
DDE/DDEML ?
The only true wisdom is knowing you know nothing

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2007
  • Fifty shades of code.
    • Delphi & FreePascal
Re: InterProcessCommunication to a Delphi7 app from 64 bit Windows app?
« Reply #4 on: March 30, 2023, 12:38:15 am »
Or via simple oldschool MMF ....
Demo attached.
Compile "Delphi32" folder first and run and press a button.
Compile "Lazarus64" folder second and run and press button.

Compare values inside the memo's.
On my Win10/64bit system it works.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

BosseB

  • Sr. Member
  • ****
  • Posts: 468
Re: InterProcessCommunication to a Delphi7 app from 64 bit Windows app?
« Reply #5 on: March 30, 2023, 12:48:19 am »
what specifics are stopping you to use FPC/Laz ?
I use software protection dongles originally from Rainbow Sentinel.
There is an SDK to interface with the driver they provide, and it works in Delphi7.
But when I try to port even the simplest application from D7 to Fpc it won't build because the SDK provides an obj file that implements all the API calls into the driver and the obj file generates an error when linking...

I have even gotten an updated SDK from the company with a new obj file, but that too fails. The syntax check completes successfully but when I compile I get the linker error where Fpc does not get to grips with the obj file.

There are 2 different obj files depending on the type of Delphi compiler, one for 32 bit (like Delphi7) and one for 64 bit Delphi.
I stopped using Delphi before it went 64 bit so I cannot check it.

So my "solution" now seems to be to implement a mini IPC server in Delphi7, which talks to the driver via the API provided (this works with the obj file).
In this I will translate all the used calls from the main application to the driver and send these as commands via the IPC channel.

So I need to implement the server with Delphi7 (32bit) and the client with Fpc/Lazarus (64 bit) using some kind of IPC channel.

Never done this before so I am on unknown grounds.
1) Can it be done?
2) What kind of object can I use that exists in both D7 and FPC 3.2.2?
3) Can it even be done at all? I mean 32bit <=>64bit?
--
Bo Berglund
Sweden

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: InterProcessCommunication to a Delphi7 app from 64 bit Windows app?
« Reply #6 on: March 30, 2023, 12:58:22 am »
Must be the differences of Obj File formats.
COFF etc..

The only true wisdom is knowing you know nothing

BosseB

  • Sr. Member
  • ****
  • Posts: 468
Re: InterProcessCommunication to a Delphi7 app from 64 bit Windows app?
« Reply #7 on: March 30, 2023, 12:59:39 am »
Or via simple oldschool MMF ....
Demo attached.
Compile "Delphi32" folder first and run and press a button.
Compile "Lazarus64" folder second and run and press button.

Compare values inside the memo's.
On my Win10/64bit system it works.
Thanks, I was writing my other response while you posted...
Grateful for examples like this with both ends!

I noticed that both of the sample applications were GUI style apps, is that a requirement for them to work?
I mean do they utilize the Windows message handler that requires a window to talk to?

The server in this case should not be visible (the Delphi7 app) while the client does have a visible form.
In fact one problem is how to start it running when the main app starts...

Also in principle there can be several instances of the client apps running at the same time, so does that work?
Do they get different MMF instances into the same server?

It is late now so I will test tomorrow..
--
Bo Berglund
Sweden

BosseB

  • Sr. Member
  • ****
  • Posts: 468
Re: InterProcessCommunication to a Delphi7 app from 64 bit Windows app?
« Reply #8 on: March 30, 2023, 01:01:30 am »
Must be the differences of Obj File formats.
COFF etc..
Yes that is the case according to other experts.
But I have no way to correct that. Must use what the supplier provides.
Apparently Fpc cannot link the obj files that Delphi can handle. :(
--
Bo Berglund
Sweden

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: InterProcessCommunication to a Delphi7 app from 64 bit Windows app?
« Reply #9 on: March 30, 2023, 01:05:58 am »
Hmm
ok, I don't think the IPC component will work between Delphi and lazarus unless you implement it also in delphi from Laz source code?

 In any case, you can use messages to post the WM_COPYDATA message.

One app can be the server and all the clients simply post a message to it for a request etc.

 But there is one thing That may need attention when using this message, you may need to play with the message filtering in windows because it's possible this is one message that could be blocked on standard user leve.
The only true wisdom is knowing you know nothing

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2007
  • Fifty shades of code.
    • Delphi & FreePascal
Re: InterProcessCommunication to a Delphi7 app from 64 bit Windows app?
« Reply #10 on: March 30, 2023, 01:15:01 am »
Or via simple oldschool MMF ....
Demo attached.
Compile "Delphi32" folder first and run and press a button.
Compile "Lazarus64" folder second and run and press button.

Compare values inside the memo's.
On my Win10/64bit system it works.
Thanks, I was writing my other response while you posted...
Grateful for examples like this with both ends!

I noticed that both of the sample applications were GUI style apps, is that a requirement for them to work?
I mean do they utilize the Windows message handler that requires a window to talk to?

The server in this case should not be visible (the Delphi7 app) while the client does have a visible form.
In fact one problem is how to start it running when the main app starts...

Also in principle there can be several instances of the client apps running at the same time, so does that work?
Do they get different MMF instances into the same server?

It is late now so I will test tomorrow..
I've just choosen GUI for easier demonstration, it is no requirement. Anyway, you would need to poll to check for new data compared to old...
Running multiple instances of Server (Delphi32) will not work since only one can be the master in that scenario, multiple Clients (Lazarus64) are no problem.
Yeah, test and play with it a little to find out if it match your needs.

WM_COPYDATA
I dont think that sharing data between 32 and 64 bit works due different LPARAM sizes... but havent tested.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

440bx

  • Hero Member
  • *****
  • Posts: 3946
Re: InterProcessCommunication to a Delphi7 app from 64 bit Windows app?
« Reply #11 on: March 30, 2023, 03:55:57 am »
Just a thought...

I would use memory mapped files for IPC, that ensures high performance and, in most cases, reasonably simple synchronization.

HTH.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Zvoni

  • Hero Member
  • *****
  • Posts: 2319
Re: InterProcessCommunication to a Delphi7 app from 64 bit Windows app?
« Reply #12 on: March 30, 2023, 11:45:08 am »
What about SimpleIPC?
https://wiki.freepascal.org/SimpleIPC
https://github.com/z505/SimpleIPC-lib

On Github there is a demo for Lazarus, and a separate demo for Delphi.
No mention of 32 vs 64-Bit though
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

BosseB

  • Sr. Member
  • ****
  • Posts: 468
Re: InterProcessCommunication to a Delphi7 app from 64 bit Windows app?
« Reply #13 on: March 30, 2023, 12:17:52 pm »
What about SimpleIPC?
https://wiki.freepascal.org/SimpleIPC
https://github.com/z505/SimpleIPC-lib

On Github there is a demo for Lazarus, and a separate demo for Delphi.
No mention of 32 vs 64-Bit though

It seems like it is a good way not to re-invent the wheel...

The issue I have but it can be tested I guess:
If I use this system for IPC, will it be able to communicate between 32 bit and 64 bit applications on Windows?
My only working comm case to the protection device is to use 32 bit Delphi7 as the server but my clients will obviously all be 64 bit since they are built with present day tools (normally Lazarus/Fpc).

Can a pipe or whatever it is called that it uses traverse the 32/64 bit border on Windows?
--
Bo Berglund
Sweden

Zvoni

  • Hero Member
  • *****
  • Posts: 2319
Re: InterProcessCommunication to a Delphi7 app from 64 bit Windows app?
« Reply #14 on: March 30, 2023, 12:33:28 pm »
As far as i could find out: There should be no problem whatsoever, since you're only sending messages
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

 

TinyPortal © 2005-2018