A Service API

Environment: VC6, NT/Windows 2000

Service API...

The Service API consists of a set of functions and a couple of callback functions that must be supported. Together, these functions allow an application to run independent of any logged-on user.

At its heart, a service application supports at least three functions:

  • The main function. This is just a standard main function with arguments like any console-mode, Win32 application. The main function must call certain functions in a timely manner.
  • VOID  main( DWORD dwArgc, LPTSTR* lpszArgv );
  • The ServiceMain function. This is the entry point for the service. The ServiceMain function must have the following prototype, though it can have a different name:
  • VOID ServiceMain( DWORD dwArgc,  LPTSTR* lpszArgv );
  • The control handler (Handler) function. This function receives requests for the service. The control handler function must have the following prototype, though it can have a different name:
  • VOID WINAPI Handler(DWORD fdwControl ); 
    DWORD WINAPI HandlerEx(
      DWORD dwControl,     // requested control code
      DWORD dwEventType,   // event type
      LPVOID lpEventData,  // event data
      LPVOID lpContext     // user-defined context data

The HandlerEx function is primarily useful for services that need to manage multiple services from a single control handler or for a service that needs to react to device notifications.


Download source - 38.4 Kb


  • easy...but how to create a service in a dll to run from svchost?

    Posted by Legacy on 05/25/2003 12:00am

    Originally posted by: geecka


    this is easy but how to create a service in a dll(like many system services) to be run from svchost service?
    i didn't find any documentation on the net about this....

  • service shutdown not done durint system shutdown.

    Posted by Legacy on 02/09/2003 12:00am

    Originally posted by: denjolras

    Under Win 2000,
    The service start and stop correctly.
    BUT during a system shutdown the service is killed.
    How to prevent system shutdown until the service was successfully stopped ?

  • Win2k Kernel mode Vs User Mode

    Posted by Legacy on 01/24/2003 12:00am

    Originally posted by: Jaideep

    I wanted to write a Service/program which will be able to identify when the OS moves from Kernel state to the user state (through source code)??? For example when a User Logs onto the Windows - I wanted to capture the two states, and take action accordingly.

    Are there any API for the said purpose???

    Please help.

  • help me in api

    Posted by Legacy on 08/08/2002 12:00am

    Originally posted by: fawadehsan

    I am newly enter in vc++. i made a program of attandance of user in a LAN. I am using a "api of net user get info" which give the information of the user status. For example user name, user fullname, last logon time, last logoff time. etc. This api give the right output for the NT user workstation. But that user who use window 2000 this api did not give right out put . The problem in the user last log off. That right in window(NT). But no right in Window 2000.
    for last logoff.
    can any body help me.


  • do you know how to start a screen saver in a program

    Posted by Legacy on 08/07/2002 12:00am

    Originally posted by: zhigang Li

    For example, you leave your program for more than 10 minutes, then the PC should be locked by a screen saver. I use "system" lile "system(screensavername.scr)". But unfortunately it does not work.

    Thanks for help!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Savvy enterprises are discovering that the cloud holds the power to transform IT processes and support business objectives. IT departments can use the cloud to redefine the continuum of development and operations—a process that is becoming known as DevOps. Download the Executive Brief DevOps: Why IT Operations Managers Should Care About the Cloud—prepared by Frost & Sullivan and sponsored by IBM—to learn how IBM SmartCloud Application services provide a robust platform that streamlines …

  • Java developers know that testing code changes can be a huge pain, and waiting for an application to redeploy after a code fix can take an eternity. Wouldn't it be great if you could see your code changes immediately, fine-tune, debug, explore and deploy code without waiting for ages? In this white paper, find out how that's possible with a Java plugin that drastically changes the way you develop, test and run Java applications. Discover the advantages of this plugin, and the changes you can expect to see …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds