You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
2.6 KiB

26 years ago
26 years ago
26 years ago
26 years ago
  1. #ifndef NT_SERVC_INCLUDED
  2. #define NT_SERVC_INCLUDED
  3. /**
  4. @file
  5. @brief
  6. Windows NT Service class library
  7. Copyright Abandoned 1998 Irena Pancirov - Irnet Snc
  8. This file is public domain and comes with NO WARRANTY of any kind
  9. */
  10. // main application thread
  11. typedef void (*THREAD_FC)(void *);
  12. class NTService
  13. {
  14. public:
  15. NTService();
  16. ~NTService();
  17. BOOL bOsNT; ///< true if OS is NT, false for Win95
  18. //install optinos
  19. DWORD dwDesiredAccess;
  20. DWORD dwServiceType;
  21. DWORD dwStartType;
  22. DWORD dwErrorControl;
  23. LPSTR szLoadOrderGroup;
  24. LPDWORD lpdwTagID;
  25. LPSTR szDependencies;
  26. OSVERSIONINFO osVer;
  27. // time-out (in milisec)
  28. int nStartTimeOut;
  29. int nStopTimeOut;
  30. int nPauseTimeOut;
  31. int nResumeTimeOut;
  32. //
  33. DWORD my_argc;
  34. LPTSTR *my_argv;
  35. HANDLE hShutdownEvent;
  36. int nError;
  37. DWORD dwState;
  38. BOOL GetOS(); // returns TRUE if WinNT
  39. BOOL IsNT() { return bOsNT;}
  40. //init service entry point
  41. long Init(LPCSTR szInternName,void *ServiceThread);
  42. //application shutdown event
  43. void SetShutdownEvent(HANDLE hEvent){ hShutdownEvent=hEvent; }
  44. //service install / un-install
  45. BOOL Install(int startType,LPCSTR szInternName,LPCSTR szDisplayName,
  46. LPCSTR szFullPath, LPCSTR szAccountName=NULL,
  47. LPCSTR szPassword=NULL);
  48. BOOL SeekStatus(LPCSTR szInternName, int OperationType);
  49. BOOL Remove(LPCSTR szInternName);
  50. BOOL IsService(LPCSTR ServiceName);
  51. BOOL got_service_option(char **argv, char *service_option);
  52. BOOL is_super_user();
  53. /*
  54. SetRunning() is to be called by the application
  55. when initialization completes and it can accept
  56. stop request
  57. */
  58. void SetRunning(void);
  59. /*
  60. Stop() is to be called by the application to stop
  61. the service
  62. */
  63. void Stop(void);
  64. protected:
  65. LPSTR ServiceName;
  66. HANDLE hExitEvent;
  67. SERVICE_STATUS_HANDLE hServiceStatusHandle;
  68. BOOL bPause;
  69. BOOL bRunning;
  70. HANDLE hThreadHandle;
  71. THREAD_FC fpServiceThread;
  72. void PauseService();
  73. void ResumeService();
  74. void StopService();
  75. BOOL StartService();
  76. static void ServiceMain(DWORD argc, LPTSTR *argv);
  77. static void ServiceCtrlHandler (DWORD ctrlCode);
  78. void Exit(DWORD error);
  79. BOOL SetStatus (DWORD dwCurrentState,DWORD dwWin32ExitCode,
  80. DWORD dwServiceSpecificExitCode,
  81. DWORD dwCheckPoint,DWORD dwWaitHint);
  82. };
  83. /* ------------------------- the end -------------------------------------- */
  84. #endif /* NT_SERVC_INCLUDED */