tags:

views:

192

answers:

3

Hello every body:

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.

I am sorry about my english...

Thanks.

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?

Thanks.

+9  A: 

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.

Remy Lebeau - TeamB
+5  A: 

I'd suggest named pipes. Someone on SO already provided a great example in Delphi (there are other examples on this site too)

Mick
+1 for directing to another answer than yours... :)
François
A: 

I use the Indy TCP Server with my Services and then I can communicate from the same machine or from other machines. It was a snap to add. I send a record back and forth, the beginning of the record tells the server what type of message and what the buffer contains and visa versa.

Richard

Richard