mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / server-tools / instance-manager / WindowsService.h
blobc45bc5c2eadae1d5e3c6c93cdee6bfa8fc44343d
1 /* Copyright (c) 2005-2007 MySQL AB
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16 #pragma once
18 class WindowsService
20 protected:
21 bool inited;
22 const char *serviceName;
23 const char *displayName;
24 SERVICE_STATUS_HANDLE statusHandle;
25 DWORD statusCheckpoint;
26 SERVICE_STATUS status;
27 DWORD dwAcceptedControls;
28 bool debugging;
30 public:
31 WindowsService(const char *p_serviceName, const char *p_displayName);
32 ~WindowsService(void);
34 BOOL Install(const char *username, const char *password);
35 BOOL Remove();
36 BOOL Init();
37 BOOL IsInstalled();
38 void SetAcceptedControls(DWORD acceptedControls);
39 void Debug(bool debugFlag) { debugging= debugFlag; }
41 public:
42 static void WINAPI ServiceMain(DWORD argc, LPTSTR *argv);
43 static void WINAPI ControlHandler(DWORD CtrlType);
45 protected:
46 virtual void Run(DWORD argc, LPTSTR *argv)= 0;
47 virtual void Stop() {}
48 virtual void Shutdown() {}
49 virtual void Pause() {}
50 virtual void Continue() {}
51 virtual void Log(const char *msg) {}
53 BOOL ReportStatus(DWORD currentStatus, DWORD waitHint= 3000, DWORD dwError=0);
54 void HandleControlCode(DWORD opcode);
55 void RegisterAndRun(DWORD argc, LPTSTR *argv);