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

  • Relying on outside companies to manage your network and server environments for your business and applications to meet the needs and demands of your users can be stressful. This is especially true as many Managed Hosting organizations fail to meet their service level agreements. Read this Forrester total economic impact report and learn what makes INetU different and how they exceed their customers' managed hosting expectations.

  • On-demand Event Event Date: January 28, 2015 Check out this webcast and join Jeff Sloyer, IBM Developer Evangelist and Master Inventor, for a tutorial for building cloud-based applications. Using IBM's platform as a service, Bluemix, Jeff will show you how to architect and assemble cloud-based applications built for cloud scale. Leveraging the power of microservices, developers can quickly translate monolithic applications to a cloud-based microarchitecture. This hour-long session introduces the concepts and …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date