Home arrow Delphi-Kylix arrow Internet Access: Client Service

Internet Access: Client Service

When a workstation is switched on in our Internet cafe we need to have a way of ensuring that the client application, which communicates with the server, is also started. There are two ways of doing this: manually and automatically. You will probably want the application to load automatically. Windows services will let us accomplish this task. Keep reading to find out what they are and how to use them.

Author Info:
By: David Web
Rating: 5 stars5 stars5 stars5 stars5 stars / 3
October 13, 2008
  1. · Internet Access: Client Service
  2. · The service application code
  3. · Code Explained
  4. · To Install/Uninstall the service

print this article

Internet Access: Client Service
(Page 1 of 4 )

If you choose to load the application manually, a staff member in our Internet café must go to each workstation, switch it on and then start the client application. This is fine if the Internet café has only a couple of workstations, however if it has more than, say, twenty workstations, this can be a bit overwhelming.

If the application is loaded automatically, then it starts by itself when a workstation is switched on. It just means that the only thing a staff member will need to do is switch on the workstations, and the client application will then be loaded as part of the startup process. This is a small improvement, but nevertheless, it is an improvement.

This is where the Windows service comes in. In the following sections we will discuss what a Windows service is and then create one for our client application.

The Windows service

What is a Windows service? It is basically an application that runs in the background. By this I mean that the application cannot be seen on the desktop while it is carrying out its functions. At any given time there are more than five processes running on your computer. You can check this by pressing cntrl+alt+del, which will bring up the task manager (on Windows) and then selecting the Processes tab. You will see a great many services running.

So how do we create one? Delphi makes it very easy to create such a service. Select the menu items File|New| Other, select "Service Application" and click OK. You now have the framework for a service application which includes a TService class. It should look something like this:

unit Unit1;



Windows, Messages, SysUtils, Classes, Graphics, Controls, SvcMgr, Dialogs;


TService1 = class(TService)


{ Private declarations }


function GetServiceController: TServiceController; override;

{ Public declarations }



Service1: TService1;


{$R *.DFM}

procedure ServiceController(CtrlCode: DWord); stdcall;




function TService1.GetServiceController: TServiceController;


Result := ServiceController;



The TService class is where we will write our code.  It also has a number of properties which you can see in the Object Inspector. Among these are (in order of appearance):

Displayname - The DisplayName is used for displaying when you use the Control Panel, Administration, Services applet.

Interactive – This property simply checks to see if the service is going to interact with a user. Most services don’t, so you can safely set this to false.

Servicestartname - You can specify an account name in this property and a password in the Password property to specify which account the service should log on as.

That requires that you know at design time the account name and password. Most of us won't know this. Just leave ServiceStartName and Password empty. You can always enter an account name and password in the service properties after the service has been installed.

A service runs as a specific user. This means that a service has the same access permissions to different things, such as folders, as the account under which the service runs. Many services run as "Local System" unless you specify a specific username when installing the service. For many things, "Local System" is sufficient; however, if the service needs to have access to things such as a folder on a network drive/share (which are normally user/password protected) you may need to specify an account which has been granted access to the network share.

Name - It's important to choose a good name, because when installing the service this name is automatically used to create a key in the registry under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services. Giving your service a name that is already registered in the registry will cause a conflict in the registry, so make sure that the name is unique.

blog comments powered by Disqus

- Loading an XML Document into the DOM
- Delphi Wrapper Classes and XML
- Delphi and the DOM
- Delphi and XML
- Internet Access: Client Service
- Finishing the Client for an Internet Access ...
- The Client for an Internet Access Control Ap...
- User Management for an Internet Access Contr...
- Important Procedures for an Internet Access ...
- Server Code for an Internet Access Control A...
- Constructing the Interface for an Internet A...
- Building a Server Application for an Interne...
- Building an Internet Access Control Applicat...
- Client Dataset: Working with Data Packets an...
- Using the Client Dataset in an N-Tiered Appl...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials