Send windows message to a Windows Service

softwarematter picture softwarematter · Aug 5, 2009 · Viewed 13.1k times · Source

Is there any tool to send (mimic) a windows message like 'WM_ENDSESSION' to a windows service?

OR

How can I send a windows message to a process using C#?

(I know only C#)

EDIT: Purpose: Basically I have to debug a windows service for fixing a bug that occurs only on system shut down.

Answer

Diaa Sami picture Diaa Sami · Aug 5, 2009

Services should be controlled using ServiceController class

Represents a Windows service and allows you to connect to a running or stopped service, manipulate it, or get information about it.

You can use it to start, stop and communicate with services using this class.