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

  • Live Event Date: December 11, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Market pressures to move more quickly and develop innovative applications are forcing organizations to rethink how they develop and release applications. The combination of public clouds and physical back-end infrastructures are a means to get applications out faster. However, these hybrid solutions complicate DevOps adoption, with application delivery pipelines that span across complex hybrid cloud and non-cloud environments. Check out this …

  • VMware vCloud® Government Service provided by Carpathia® is an enterprise-class hybrid cloud service that delivers the tried and tested VMware capabilities widely used by government organizations today, with the added security and compliance assurance of FedRAMP authorization. The hybrid cloud is becoming more and more prevalent – in fact, nearly three-fourths of large enterprises expect to have hybrid deployments by 2015, according to a recent Gartner analyst report. Learn about the benefits of …

Most Popular Programming Stories

More for Developers

RSS Feeds