Home arrow Delphi-Kylix arrow Page 2 - Creating a Windows Service in Delphi
DELPHI-KYLIX

Creating a Windows Service in Delphi


Service applications let you check for updates on a system or monitor system resources, without interrupting your work. While they can be difficult to create, Delphi makes it simple. This article explains how to create a simple Windows service application in Delphi, which you can build on and modify to suit your own needs.

Author Info:
By: Jacques Noah
Rating: 5 stars5 stars5 stars5 stars5 stars / 93
February 08, 2006
TABLE OF CONTENTS:
  1. · Creating a Windows Service in Delphi
  2. · Let’s Create a Service
  3. · The Code
  4. · Installing/Uninstalling the Service
  5. · Entire Code for the Service Application

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Creating a Windows Service in Delphi - Let’s Create a Service
(Page 2 of 5 )

Our service is going to write the time and date to a text file every minute or so. So, start up Delphi and select File->New->Other. Then select "Service Application."



Add a timer, set it to 60000 (one minute), save the project and unit, and familiarize yourself with the code structure. As you’ve no doubt noticed, the application declaration is different from the standard application. Go to the object inspector and have a look at the various properties of the service application.

Let’s go through what each of them mean:

AllowPause and AllowStop properties are self explanatory. You need to set these to true.

DisplayName specifies the name of the service in the Service Control Manager or Task Manager; enter any name you want in here.

The Interactive property specifies whether the Service should be able to communicate with the desktop (for example, with ShowMessage). This will normally depend on what kind of service you are creating. For our service we will normally not need any interaction with the desktop, but for the purposes of this tutorial we will set it to true.

The ServiceStartName and Password properties specify the account that the service should be operating as.

The ServiceType is set to stWin32 for a Win32 Service, and the StartType property can be stAuto, stBoot, stDisabled, stManual, or stSystem (but for a Win32 service, only Auto, Manual, and System are relevant).


blog comments powered by Disqus
DELPHI-KYLIX ARTICLES

- 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...

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



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