I have only created regular windows applications (C# mostly). What differentiates a windows service from a regular windows application? What makes them different? What can a service do that an application can't? What are the differences seen from a developers point of view? How do you create one? Is it just to create a regular application (Console application maybe, since there are no gui?) and run or install it in a special way, or is it more that has to be done?
An application is software that is designed to be installed and managed by users. A service is software that is managed for users. This includes services such as APIs that users never use directly. It also includes services such as a website that people use but don't install and manage for themselves.
Microsoft Windows services, formerly known as NT services, enable you to create long-running executable applications that run in their own Windows sessions. These services can be automatically started when the computer boots, can be paused and restarted, and do not show any user interface.
In Windows NT operating systems, a Windows service is a computer program that operates in the background. It is similar in concept to a Unix daemon. A Windows service must conform to the interface rules and protocols of the Service Control Manager, the component responsible for managing Windows services.
You would typically use Windows services to implement long-running jobs that will be executed at predefined intervals of time. Your Windows service will continue to run in the background while the applications in your system can execute at the same time.
There are a couple of things that jump out to me immediately.
This MSDN page leads to more documentation on creating them than you could shake a stick at. This page is perhaps a better introduction to them in general.
The key difference between a process running as an app versus as a service is that the service can operate entirely outside the normal association with a user and session. Thus services can run such that they start before any user logs in and can continue running after users log off. Services are thus used to implement a great deal of the actual functionality of the operating system.
Services are also not tied to running as a 1:1 mapping with a process. Many services can exist within one process, normally through the use of svchost (take a look at these with process explorer for an indication of how this often works). This reduces the effort at startup as multiple processes are not required for relatively lightweight services.
Implementing a service in c# is pretty simple, this page indicates how in very easy to follow terms.
Note that in reality a service in windows is little more that the scaffolding in the registry under HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services which defines those 'image paths' (in most cases simply executables and the parameters to use) which are considered services along with which user then run as, which other services they depend on and whether they start at start up/post start up or as required.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With