summaryrefslogtreecommitdiff
path: root/examples/NT_Service/README
blob: a1d4175e1262adbe3df0d0f98fece13317b92d17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
$Id$

How to use the NT_Service example.

The NT_Service program has the following usage:  -in -r -s -k -tn -d
  -i: Install this program as an NT service, with specified startup
  -r: Remove this program from the Service Manager
  -s: Start the service
  -k: Kill the service
  -t: Set startup for an existing service
  -d: Debug; run as a regular application

In order to see different stages of an NT service application,
you have to run the program several times, with different options.
Please note: run with only one option at a time.

1. Make executable NT_Service.

2. First, you must initialize the service in the NT SCM database.
   Run NT_Service with -in, where n is one of the following startup options:

        //
        // Start Type (from WinNT.h)
        //
        #define SERVICE_SYSTEM_START    0x00000001
        #define SERVICE_AUTO_START      0x00000002
        #define SERVICE_DEMAND_START    0x00000003
        #define SERVICE_DISABLED        0x00000004

   If only -i is specified, SERVICE_AUTO_START is default option.

3. Now you are ready to run the actual service. Run NT_Service again,
   this time with -s option. If the service starts successfully, it will
   ring the system bell every second or so until the service is stopped.

4. To stop service execution, run NT_Service with the -k option.

5. To remove the service from the Service Control Manager database, run
   NT_Service with -r.

In addition, once you have initialized this service (by using the -i option)
you can change its startup type to one of the other values above.  To do
this, run NT_Service with -tn option. n is as explained above for -i.

In order to debug the service's execution itself, use the -d option.