|
-
June 21st, 2005, 09:17 AM
#1
Create a Service...
Hi all,
I have developed a Dialog-Based application, and I want it to run as the service, when ever the system restarts.
I have tried it by creating a service using the CreateService method, the Service was created, and the service was not running when the system is restarted, I kept the service start type as (SERVICE_AUTO_START). It is giving me the error message --
'Error-1053: The service did not respond to the start or control request in a timely fashion. '
The code is ....
LPCTSTR lpszBinaryPathName = "c:\samp.exe";
SC_HANDLE schService = CreateService(
OpenSCManager(NULL,NULL,SC_MANAGER_CREATE_SERVICE),"SampService",
"Sample Server",SERVICE_ALL_ACCESS,SERVICE_WIN32_SHARE_PROCESS,
SERVICE_AUTO_START,SERVICE_ERROR_NORMAL,lpszBinaryPathName,
NULL,NULL,NULL,NULL,NULL);
---------------
or how can I make my application as a service.. my application have many projects involved in it......
Thanks in advance,
dwurity
-
June 21st, 2005, 10:09 AM
#2
Re: Create a Service...
A service is far different from a normal application.:
- A service cannot have dialog's to commuincate with the user. Only a messagebox is allowed.
- A service is a console based application
- A service must have a controler routine and a service routine, otherwise it won't work.
Here is the MSDN reference to this. And here what to do to write a service and/or controling it.
-
June 21st, 2005, 01:31 PM
#3
Re: Create a Service...
Also, you can register your service using the SC.EXE application. Not sure of its availability but I know it's on XP (for W2K, it may be in the resource kit). If you're deploying it, then you'll obviously want to code the registration, but for testing purposes SC.EXE makes it much easier.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|