Delphi 2009: How to communicate between Windows service & desktop application under Vista?

The way to go is named pipes, you’ll probably have to take a look at the communication across different Integrity levels. This article explores how to do this in vista. Although it’s written in c++ it’s just basic Windows API calls, so it should translate fast enough to Delphi. If you want to search for … Read more

Play wave file from a Windows Service (C#)

Playing a wav file from a service is definitely possible, at least on Windows 7 (and most likely Vista), by using the Windows Core Audio APIs. I recently verified this by making a small test service using NAudio. I just downloaded the NAudio sources and copied the “Wsapi” parts from their NAudioDemo project. This was … Read more

Windows Service to run a function at specified time

(1) On first start, Set _timer.Interval to the amount of milliseconds between the service start and schedule time. This sample set schedule time to 7:00 a.m. as _scheduleTime = DateTime.Today.AddDays(1).AddHours(7); (2) On Timer_Elapsed, reset _timer.Interval to 24 hours (in milliseconds) if current interval is not 24 hours. System.Timers.Timer _timer; DateTime _scheduleTime; public WinService() { InitializeComponent(); … Read more

Start stop Service from Form App c#

Add a reference to System.ServiceProcess.dll. Then you can use the ServiceController class. // Check whether the Alerter service is started. ServiceController sc = new ServiceController(); sc.ServiceName = “Alerter”; Console.WriteLine(“The Alerter service status is currently set to {0}”, sc.Status.ToString()); if (sc.Status == ServiceControllerStatus.Stopped) { // Start the service if the current status is stopped. Console.WriteLine(“Starting the … Read more

How can I set up .NET UnhandledException handling in a Windows service?

The reason that the UnhandledException event on the current AppDomain does not fire is how services are executed. User sends a Start command from the Windows Service Control Manager (SCM). The command is received by the framework’s ServiceBase implementation and dispatched to the OnStart method. The OnStart method is called. Any exception which is thrown … Read more

windows service startup timeout

I agree with Romulo on finishing to start your service as soon as possible. However, if you need the time and you are using .NET Framework 2.0 or later, you might consider ServiceBase.RequestAdditionalTime() method. http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicebase.requestadditionaltime.aspx protected override void OnStart() { this.RequestAdditionalTime(10000); // do your stuff }

Windows Service not appearing in services list after install

The most important part of the article you linked, is here To add a custom action to the setup project 1.In Solution Explorer, right-click the setup project, point to View, then choose Custom Actions. The Custom Actions editor appears. 2.In the Custom Actions editor, right-click the Custom Actions node and choose Add Custom Action. The … Read more