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 ); 
    
    Or
    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.

Downloads

Download source - 38.4 Kb


Comments

  • 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

    hi
    
    

    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....

    Reply
  • 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 ?

    Reply
  • 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.
    Jaideep.

    Reply
  • help me in api

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

    Originally posted by: fawadehsan

    Hello 
    
    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.


    fawad

    Reply
  • 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!

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

Top White Papers and Webcasts

  • Packaged application development teams frequently operate with limited testing environments due to time and labor constraints. By virtualizing the entire application stack, packaged application development teams can deliver business results faster, at higher quality, and with lower risk.

  • Do you know where your data is? Consumer cloud-based file sharing services store your sensitive company data on servers outside of your control, outside of your policy and regulatory guidelines – maybe even outside your country – and not managed by you. The potential for data leakage, security breaches, and harm to your business is enormous. Download this white paper to learn about file sync and share alternatives that allow you to manage and protect your sensitive data while integrating and …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds