dsrc isn't necessary for this repo
[client-tools.git] / src / external / 3rd / library / perforce / include / ntservice.h
blobc34ebefbb2ee6d17ef7ef9efb43ee1bcda3d9349
1 /*
2 * Copyright 1995, 2000 Perforce Software. All rights reserved.
4 * This file is part of Perforce - the FAST SCM System.
5 */
7 /*
8 * NtService - Class allows Perforce server to run as a service on NT.
10 * Public methods:
12 * NtService::NtService()
13 * Constructor requires a name, and a pointer to the entry point for
14 * the program which can not be main because main calls
15 * StartServiceControlDispatcher() and never returns.
17 * NtService::Start()
18 * This calls StartServiceControlDispatcher to connect the service to
19 * the SCM. This should be called as soon as possible after the
20 * program starts because the SCM will only wait 30 seconds for this
21 * call.
23 * NtService::SetStatus()
24 * Informx SCM of changes in the services status. Required to tell
25 * SCM when service has successfully started.
29 #ifndef NTSERVICE_H__
30 #define NTSERVICE_H__
32 class NtService
34 public:
35 enum states
37 stopped,
38 running,
39 start_pending,
40 stop_pending,
41 paused,
42 pause_pending,
43 continue_pending,
44 no_change
47 NtService();
48 virtual ~NtService();
50 // Our caller's interface
52 virtual void Start( int (*entryPt)( DWORD, char ** ), char *svc );
54 virtual void SetStatus(
55 states state = no_change,
56 DWORD win32_exitcode = 0,
57 DWORD specific_code = 0,
58 DWORD wait_hint = 0 );
60 private:
62 // SCM callbacks with Win32 interfaces.
63 // Do not call them directly.
64 // Because they are static, we have to remember
65 // the (one) NtService in use.
67 static NtService *global_this;
68 static void WINAPI ControlHandler( DWORD opcode );
69 static void StaticRun( DWORD argc, char **argv );
71 // Called by ControlHanlder
73 virtual void Run( DWORD argc, char **argv );
74 virtual void Stop();
76 SERVICE_STATUS status;
77 SERVICE_STATUS_HANDLE statusHandle;
79 int ( *entry_point )( DWORD, char ** );
81 char svcName[32];
84 #endif // NTSERVICE_H__