How to communicate with Windows Service in C#?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I created a CE Windows Service in C++ and a client test harness. Now I am
trying to create 2nd test harness in C# to call the same service. Is it
possible? The (XP) .NET class ServiceController is unavailable in compact
framework.

I'd apprecaite if someone can shed some light.
 
That's because services on Windows CE don't behave or look like desktop
services in NT and higher. What are you trying to do to the service?
Start/stop it? ActivateService()? RegisterService?

Paul T.
 
I would like to invoke the service's XXX_IOControl interface and pass data
buffers in and out via this interface. I'd proven this functionality using
C++ client. The challenge is to make this work using C# and .NET Compact
Framework.

Any suggestion is greatly appreciated.

-c

Paul G. Tobey said:
That's because services on Windows CE don't behave or look like desktop
services in NT and higher. What are you trying to do to the service?
Start/stop it? ActivateService()? RegisterService?

Paul T.
 
OK, if the 'service' has a stream driver interface, you should be able to do
*exactly* what you did in C++ from C#, although you'll have to P/Invoke to
get to the calls that you need to make. You did something like hdl =
CreateFile( deviceName, ... ), DeviceIoControl( hdl, ... ) in your C++ code?
If so, look at OpenNETCF's SDF. The FileEx class gives you access to
CreateFile() and DeviceIoControl(). If you're calling GetServiceHandle()
and ServiceIoControl() in C++, you'll have to write your own P/Invoke
declarations for those, but they should be pretty similar in form to the
declarations in OpenNETCF.

If you can tell us what you're actually *doing* in C++, you'll get a much
better reply!

Paul T.

Charles Chiang said:
I would like to invoke the service's XXX_IOControl interface and pass data
buffers in and out via this interface. I'd proven this functionality
using
C++ client. The challenge is to make this work using C# and .NET Compact
Framework.

Any suggestion is greatly appreciated.

-c
 
I'd suspected that might be the most reasonable route after some personal
research. Thank you very much for your help.

FYI, I am using 'GetServiceHandle' and 'ServiceIoControl' in my C++ client
to communicate with the service.

-c
 
Back
Top