Example: Skype will be the application to trigger my service, if skype opens then my service should start. If skype closes then my service should close. Is that possible?
I want to put the status in my eventLog to check if it indeed works using something like this:
protected override void OnStart(string[] args)
{
galaxyeventLog.WriteEntry("Skype Start");
}
protected override void OnStop()
{
galaxyeventLog.WriteEntry("Skype Stop");
}
Here is how you can do it
You need to develop a SkypeMonitor service (a third service application). Its job is to track the Skype process. This can be done using WMI interface. Sample code can be found in
.NET Process Monitor
Using it you can hook into the start and stop skype process events to start / stop your service using the code below
ServiceController controller = new ServiceController(serviceName);
if (controller.Status==ServiceControllerStatus.Stopped)
controller.Start();