Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send a message to a service?

Tags:

delphi

We are trying to develop an application that send messages to a service, but we only have send message between two applications. We are developing in Delphi 7, Windows XP.

We need the service send back a message to the application, depending on the result of the action that the application sent to do to the service.

Well, some people said that it's impossible to send a message from an application to a service. So, we decided to make two services, and now we have to send messages from one service to another one. Now, the point is: how to send a message from a service to another one?

like image 875
Howard Avatar asked Nov 30 '22 10:11

Howard


1 Answers

You cannot send window messages to a service. For one, services do not have a UI of their own, let alone windows. And second, even if you add your own hidden window to the service (actually, Delphi-based services do have the hidden TApplication window), window messages are not allowed to pass over session boundaries (services run in a separate session than user-mode applications).

There are many IPC (interprocess communications) mechanisms that work with services - named pipes, mailslots, TCP/IP and UDP sockets, just to name a few. You will have to use one of those instead.

like image 63
Remy Lebeau Avatar answered Dec 09 '22 13:12

Remy Lebeau