Yes I'm doing this, but still not working
Main Topics
Browse All TopicsHi Experts
I'm trying to create a service in delphi, but is not working. I am using delphi 7 and windows xp professional.
What's wrong with this code
Alexandre
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
To start and stop services programatically, you have to use the ServiceControlManager. You can read all about it in the Win32 SDK help. What you do is that you allocate a handle to the ServiceControlManager, from which you can then request a handle to the service you want to start, by calling OpenService and providing the service name as a parameter. When you have a handle to the service, you can call the function StartService to Start; or ControlService with parameter SERVICE_CONTROL_STOP to stop the service. The service needs to be installed on your computer for this to work.
The example I've provided below uses the default service database on the local computer, which is where I assume your service will exist, but you can also connect to other databases or other computers by submitting the correct parameters to the OpenSCManager call.
Create an application with two buttons and a TEdit, and then add the code I've provided below. Button1 will start the service named by Edit1, and Button2 will stop the service.
regards
Hypo
Business Accounts
Answer for Membership
by: Geert_GruwezPosted on 2009-04-06 at 14:27:24ID: 24081890
how are you trying to run this ?
you need to run it from the cmd prompt
service.exe /install