TROWinMessageChannel and Windows Service

Hi,

I want to add message log capability to my windows Service, I mean I have a application that act as TROWinMessage Server and the Windows Service act as a client, and everything done in the Windows service is send to the app server to log it.

does TROWinMessageChannel is compatible with Window service ? My service seems to fail when it call the service.

What other king of Channel/server should I use to work on the same computer as the app server ?

best regards

WinMessage server & client can communicate only if they are launched under the same user. in your case, seems, they are launched under different accounts.
for your purposes, you can use DLLServer or NamePipe server

Thanks Evgeny for your reply.
I use now NamedPipe server.
But how can I know if the server is active, it seems that my app crash if the server is not launched ?
Best regards

I can’t reproduce any crash with the Named Pipe sample.
probably you don’t set all required properties of TRONamedPipeChannel

Evgeny,

the main difference is that my Windows service is a client, not a server…
Is RO sample, if I try to use the client and I don’t run the server, it display an error message.
Does it do the same with a windows service that doesn’t alow message to be sent on screen ?

Regards

why you can’t put server method call into try/except and handle exception in except section?

That’s what I have finally done but still untested.
But is there a way to test if server is running on RO ?

you can call ROChannel.Connect - it will raise exception if server isn’t available.

if you like to do this w/o exception, you can use something like

    hPipe := CreateFile(
       pchar('\\' + ROChannel.ServerName + '\pipe\' + ROChannel.ServerID),   // pipe name
       GENERIC_READ or       // read and write access
       GENERIC_WRITE,
       0,              // no sharing
       nil,            // no security attributes
       OPEN_EXISTING,  // opens existing pipe
       0,              // default attributes
       0);             // no template file
   result := not (hPipe= INVALID_HANDLE_VALUE);
   if result then CloseHandle(hPipe);

Great !
Thanks Evgeny.