CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2004
    Location
    Chennai, India.
    Posts
    380

    Thumbs up 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

  2. #2
    Join Date
    Mar 2004
    Location
    (Upper-) Austria
    Posts
    2,899

    Re: Create a Service...

    A service is far different from a normal application.:

    1. A service cannot have dialog's to commuincate with the user. Only a messagebox is allowed.
    2. A service is a console based application
    3. 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.
    I am not offering technical guidiance via email or IM
    Come on share your photo with us! CG members photo album!
    Use the Code Tags!

  3. #3
    Join Date
    May 2004
    Location
    Michigan, United States
    Posts
    457

    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
  •  





Click Here to Expand Forum to Full Width

Featured