Hi,
I'd like to design a software that is mainly made of a service and that
would need a user interface to view and edit the configuration.

Now, what I need to know is: Is it possible for an independant exe to
connect to a service and get data from it or send data to it? If it's
possible, what is the best way to do it?

Thanks

Re: How can I communicate with a service? by William

William
Mon Mar 01 12:47:47 CST 2004

"ThunderMusic" <NOdanylat@sympatico.caSPAM> wrote in message
news:eTChru7$DHA.2180@TK2MSFTNGP09.phx.gbl...
> Now, what I need to know is: Is it possible for an independant exe to
> connect to a service and get data from it or send data to it? If it's
> possible, what is the best way to do it?

Yes. You can use sockets, pipes, mailslots, RPC, (D?)COM, Windows messages,
DDE, APC's etc.

I often choose pipes because

1) they are simple
2) they can be message oriented
3) they are impersonable
4) they are securable

Regards,
Will




Re: How can I communicate with a service? by William

William
Mon Mar 01 12:50:37 CST 2004

"William DePalo [MVP VC++]" <willd.no.spam@mvps.org> wrote in message
news:%23s6Ft27$DHA.2072@TK2MSFTNGP11.phx.gbl...
> Yes. You can use sockets, pipes, mailslots, RPC, (D?)COM, Windows
messages,
> DDE, APC's etc.

Mea culpa.

While it is true that you can use Windows messages and that it is done, I
shouldn't have suggested it as it requires that your service have access to
the desktop which is not wise.

Regards,
Will



Re: How can I communicate with a service? by ThunderMusic

ThunderMusic
Mon Mar 01 12:57:13 CST 2004

thank you very much, I'll see what I can learn on pipes...

"William DePalo [MVP VC++]" <willd.no.spam@mvps.org> wrote in message
news:%23orZS47$DHA.1036@TK2MSFTNGP10.phx.gbl...
> "William DePalo [MVP VC++]" <willd.no.spam@mvps.org> wrote in message
> news:%23s6Ft27$DHA.2072@TK2MSFTNGP11.phx.gbl...
> > Yes. You can use sockets, pipes, mailslots, RPC, (D?)COM, Windows
> messages,
> > DDE, APC's etc.
>
> Mea culpa.
>
> While it is true that you can use Windows messages and that it is done, I
> shouldn't have suggested it as it requires that your service have access
to
> the desktop which is not wise.
>
> Regards,
> Will
>
>



Re: How can I communicate with a service? by ThunderMusic

ThunderMusic
Mon Mar 01 14:32:52 CST 2004

ok, so I've read about pipes, but do you have some examples of communication
with pipes? because the CreatePipe or CreateNamedPipe functions are not much
documented. I mean, it tells what it has to tell, but I can't see how I can
connect both my applications (the service and the GUI) together.

Who must create the pipe? the service or the application? How can one tell
the other what are the handles for reading and writing?

There is definetly something I dont understand here...

Please help

Thanks

Thundermusic
"William DePalo [MVP VC++]" <willd.no.spam@mvps.org> wrote in message
news:%23orZS47$DHA.1036@TK2MSFTNGP10.phx.gbl...
> "William DePalo [MVP VC++]" <willd.no.spam@mvps.org> wrote in message
> news:%23s6Ft27$DHA.2072@TK2MSFTNGP11.phx.gbl...
> > Yes. You can use sockets, pipes, mailslots, RPC, (D?)COM, Windows
> messages,
> > DDE, APC's etc.
>
> Mea culpa.
>
> While it is true that you can use Windows messages and that it is done, I
> shouldn't have suggested it as it requires that your service have access
to
> the desktop which is not wise.
>
> Regards,
> Will
>
>



Re: How can I communicate with a service? by William

William
Mon Mar 01 20:51:02 CST 2004

"ThunderMusic" <NOdanylat@sympatico.caSPAM> wrote in message
news:ey7oax8$DHA.2012@TK2MSFTNGP11.phx.gbl...
> ok, so I've read about pipes, but do you
> have some examples of communication
> with pipes?

Yes. I like this sample:


http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipc/base/multithreaded_pipe_server.asp

The basic idea is that a server creates a pipe with a particular well-known
name. A little like a business with one telephone number which is serviced
by multiple telephone lines, the server can manage up to 255 "instances" of
that pipe. Each instance corresponds to one client "open" operation. The
example above creates one thread to handle each client request. This is very
easy to code and a good option if you need to support a small number of
clients.

In detail the server calls CreateNamedPipe() to make itself available to its
clients. Each client calls CreateFile() specifying the server's host name
and the name of the pipe. The client requests service by calling
WriteFile(). The server receives the request by calling ReadFile().

> Who must create the pipe? the service or the application?

The server.

> How can one tell the other what are
> the handles for reading and writing?

The client opens the pipe with CreateFile() which yields a handle. It uses
that handle to write (send). The server opens the pipe, gets and handle and
reads (receives). For responses, the opposite operations are used. When
done, each side closes its own handle.

Regards,
Will



Re: How can I communicate with a service? by ThunderMusic

ThunderMusic
Tue Mar 02 08:22:49 CST 2004

Wow!! Exactly what I was searching for.

Thanks a lot.

ThunderMusic
"William DePalo [MVP VC++]" <willd.no.spam@mvps.org> wrote in message
news:eAxTuEAAEHA.2808@TK2MSFTNGP10.phx.gbl...
> "ThunderMusic" <NOdanylat@sympatico.caSPAM> wrote in message
> news:ey7oax8$DHA.2012@TK2MSFTNGP11.phx.gbl...
> > ok, so I've read about pipes, but do you
> > have some examples of communication
> > with pipes?
>
> Yes. I like this sample:
>
>
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipc/base/multithreaded_pipe_server.asp
>
> The basic idea is that a server creates a pipe with a particular
well-known
> name. A little like a business with one telephone number which is
serviced
> by multiple telephone lines, the server can manage up to 255 "instances"
of
> that pipe. Each instance corresponds to one client "open" operation. The
> example above creates one thread to handle each client request. This is
very
> easy to code and a good option if you need to support a small number of
> clients.
>
> In detail the server calls CreateNamedPipe() to make itself available to
its
> clients. Each client calls CreateFile() specifying the server's host name
> and the name of the pipe. The client requests service by calling
> WriteFile(). The server receives the request by calling ReadFile().
>
> > Who must create the pipe? the service or the application?
>
> The server.
>
> > How can one tell the other what are
> > the handles for reading and writing?
>
> The client opens the pipe with CreateFile() which yields a handle. It uses
> that handle to write (send). The server opens the pipe, gets and handle
and
> reads (receives). For responses, the opposite operations are used. When
> done, each side closes its own handle.
>
> Regards,
> Will
>
>