5 comments. Current rating: (1 votes). Leave comments and/ or rate it.
Question:
How can I turn a regular Delphi application into a service for a Windows NT4 server?
The meaning for this is that the program should run when the server is rebooted and even when the server is not logged on. So putting the program in startup folder is not enough.
Answer:
With Delphi 5, this has become very simple.
Just go to 'File' -> 'New' -> 'Service Application'.
It will create a regular project source with one main 'form', which is derived from TService.
The TService class encapsulates a Windows NT service in an NT service application. A service is accessed via the Service Control Manager. It is usually started during boot time or manually in the control panel 'Services' applet.
The code will look as shown in the example below and consult the online help about TService. You may want to handle the OnExecute event.
Can you please tell me what could be wrong if i try to debug the service and i get 'unable to create process : access denied' when i try to attach to the service executable.
2006-09-04, 06:00:51
anonymous from United Kingdom
Question was not exactly answered. The writer wanted to know how to turn his current application into an NT Service, not how to create one from scratch which is what I believe this response is instructing.
I would also like to know how to do this. Can I just add the SERVICE as opposed to the SERVICE APPLICATION and write some code to convert my existing application to an nt service
2008-01-21, 08:57:37
[hidden]
hey baby its too easy
write this in cmd too create a Windows Services
Creating Services:
Adding Service (Note: Space between binpath= and 'C:\ has to be there.
<path>\sc.exe create 'Service Name' binPath= 'C:\Your Program.exe'
Removing Service
<path>\sc.exe delete 'Service Name'
Controlling Services:
Starting Service
<path>\sc.exe start 'Service Name'
Pausing Service
<path>\sc.exe pause 'Service Name'
Stoping Service
<path>\sc.exe stop 'Service Name
2008-07-15, 07:50:38
anonymous from India
Didnot work for me...
2008-11-23, 02:32:34
anonymous
Hi, I craete a service application using delphi7. It works fine and supported all my reqierment but I should handle OnStop or OnDestroy even of my service to do something. When service is stopped from list of services in control panel by user,it works fine, but when a user killed my service by using Task Manager Process by pushing End Process button, nor of these event are fire and I am unable to handle this event. Can aby body help me?.....