mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
859371bb5f
routines for avoid to leave the Service Control Manager in bad state. Print messages for to reduce the current user errors when are trying to install or start the service. Adding the option to install the service for manual start: --install-manual. sql/mysqld.cc: Changes on install and remove service sql/nt_servc.cc: Changes for install and remove routine. Adding the seek status routine sql/nt_servc.h: Changes for install and remove routines BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
81 lines
2.3 KiB
C++
81 lines
2.3 KiB
C++
/* ------------------------------------------------------------------------
|
|
Windows NT Service class library
|
|
Copyright Abandoned 1998 Irena Pancirov - Irnet Snc
|
|
This file is public domain and comes with NO WARRANTY of any kind
|
|
-------------------------------------------------------------------------- */
|
|
|
|
// main application thread
|
|
typedef void (*THREAD_FC)(void *);
|
|
|
|
class NTService
|
|
{
|
|
public:
|
|
NTService();
|
|
~NTService();
|
|
|
|
BOOL bOsNT; // true if OS is NT, false for Win95
|
|
//install optinos
|
|
DWORD dwDesiredAccess;
|
|
DWORD dwServiceType;
|
|
DWORD dwStartType;
|
|
DWORD dwErrorControl;
|
|
|
|
LPSTR szLoadOrderGroup;
|
|
LPDWORD lpdwTagID;
|
|
LPSTR szDependencies;
|
|
OSVERSIONINFO osVer;
|
|
|
|
// time-out (in milisec)
|
|
int nStartTimeOut;
|
|
int nStopTimeOut;
|
|
int nPauseTimeOut;
|
|
int nResumeTimeOut;
|
|
|
|
//
|
|
DWORD my_argc;
|
|
LPTSTR *my_argv;
|
|
HANDLE hShutdownEvent;
|
|
int nError;
|
|
DWORD dwState;
|
|
|
|
BOOL GetOS(); // returns TRUE if WinNT
|
|
BOOL IsNT() { return bOsNT;}
|
|
//init service entry point
|
|
long Init(LPCSTR szInternName,void *ServiceThread);
|
|
|
|
//application shutdown event
|
|
void SetShutdownEvent(HANDLE hEvent){ hShutdownEvent=hEvent; }
|
|
|
|
|
|
//service install / un-install
|
|
BOOL Install(int startType,LPCSTR szInternName,LPCSTR szDisplayName,LPCSTR szFullPath,
|
|
LPCSTR szAccountName=NULL,LPCSTR szPassword=NULL);
|
|
BOOL SeekStatus(LPCSTR szInternName, int OperationType);
|
|
BOOL Remove(LPCSTR szInternName);
|
|
|
|
void Stop(void); //to be called from app. to stop service
|
|
|
|
protected:
|
|
LPSTR ServiceName;
|
|
HANDLE hExitEvent;
|
|
SERVICE_STATUS_HANDLE hServiceStatusHandle;
|
|
BOOL bPause;
|
|
BOOL bRunning;
|
|
HANDLE hThreadHandle;
|
|
THREAD_FC fpServiceThread;
|
|
|
|
void PauseService();
|
|
void ResumeService();
|
|
void StopService();
|
|
BOOL StartService();
|
|
|
|
static void ServiceMain(DWORD argc, LPTSTR *argv);
|
|
static void ServiceCtrlHandler (DWORD ctrlCode);
|
|
|
|
void Exit(DWORD error);
|
|
BOOL SetStatus (DWORD dwCurrentState,DWORD dwWin32ExitCode,
|
|
DWORD dwServiceSpecificExitCode,
|
|
DWORD dwCheckPoint,DWORD dwWaitHint);
|
|
|
|
};
|
|
/* ------------------------- the end -------------------------------------- */
|