MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nt_servc.h
Go to the documentation of this file.
1 #ifndef NT_SERVC_INCLUDED
2 #define NT_SERVC_INCLUDED
3 
14 // main application thread
15 typedef void (*THREAD_FC)(void *);
16 
17 class NTService
18 {
19  public:
20  NTService();
21  ~NTService();
22 
23  BOOL bOsNT;
24  //install optinos
25  DWORD dwDesiredAccess;
26  DWORD dwServiceType;
27  DWORD dwStartType;
28  DWORD dwErrorControl;
29 
30  LPSTR szLoadOrderGroup;
31  LPDWORD lpdwTagID;
32  LPSTR szDependencies;
33  OSVERSIONINFO osVer;
34 
35  // time-out (in milisec)
36  int nStartTimeOut;
37  int nStopTimeOut;
38  int nPauseTimeOut;
39  int nResumeTimeOut;
40 
41  //
42  DWORD my_argc;
43  LPTSTR *my_argv;
44  HANDLE hShutdownEvent;
45  int nError;
46  DWORD dwState;
47 
48  BOOL GetOS(); // returns TRUE if WinNT
49  BOOL IsNT() { return bOsNT;}
50  //init service entry point
51  long Init(LPCSTR szInternName,void *ServiceThread);
52 
53  //application shutdown event
54  void SetShutdownEvent(HANDLE hEvent){ hShutdownEvent=hEvent; }
55 
56 
57  //service install / un-install
58  BOOL Install(int startType,LPCSTR szInternName,LPCSTR szDisplayName,
59  LPCSTR szFullPath, LPCSTR szAccountName=NULL,
60  LPCSTR szPassword=NULL);
61  BOOL SeekStatus(LPCSTR szInternName, int OperationType);
62  BOOL Remove(LPCSTR szInternName);
63  BOOL IsService(LPCSTR ServiceName);
64  BOOL got_service_option(char **argv, char *service_option);
65  BOOL is_super_user();
66 
67  /*
68  SetRunning() is to be called by the application
69  when initialization completes and it can accept
70  stop request
71  */
72  void SetRunning(void);
73 
82  void SetSlowStarting(unsigned long timeout);
83 
84  /*
85  Stop() is to be called by the application to stop
86  the service
87  */
88  void Stop(void);
89 
90  protected:
91  LPSTR ServiceName;
92  HANDLE hExitEvent;
93  SERVICE_STATUS_HANDLE hServiceStatusHandle;
94  BOOL bPause;
95  BOOL bRunning;
96  HANDLE hThreadHandle;
97  THREAD_FC fpServiceThread;
98 
99  void PauseService();
100  void ResumeService();
101  void StopService();
102  BOOL StartService();
103 
104  static void ServiceMain(DWORD argc, LPTSTR *argv);
105  static void ServiceCtrlHandler (DWORD ctrlCode);
106 
107  void Exit(DWORD error);
108  BOOL SetStatus (DWORD dwCurrentState,DWORD dwWin32ExitCode,
109  DWORD dwServiceSpecificExitCode,
110  DWORD dwCheckPoint,DWORD dwWaitHint);
111 
112 };
113 /* ------------------------- the end -------------------------------------- */
114 
115 #endif /* NT_SERVC_INCLUDED */