Source code of Windows XP (NT5)
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.

133 lines
4.4 KiB

  1. //
  2. // Copyright (C) 1993-1997 Microsoft Corporation. All Rights Reserved.
  3. //
  4. // MODULE: service.h
  5. //
  6. // AUTHOR: Craig Link
  7. //
  8. //
  9. // Comments: The use of this header file and the accompanying service.c
  10. // file simplifies the process of writting a service. You as a developer
  11. // simply need to follow the TODO's outlined in this header file, and
  12. // implement the ServiceStart() and ServiceStop() functions.
  13. //
  14. // There is no need to modify the code in service.c. Just add service.c
  15. // to your project and link with the following libraries...
  16. //
  17. // libcmt.lib kernel32.lib advapi.lib shell32.lib
  18. //
  19. // This code also supports unicode. Be sure to compile both service.c and
  20. // and code #include "service.h" with the same Unicode setting.
  21. //
  22. // Upon completion, your code will have the following command line interface
  23. //
  24. // <service exe> -? to display this list
  25. // <service exe> -install to install the service
  26. // <service exe> -remove to remove the service
  27. // <service exe> -debug <params> to run as a console app for debugging
  28. //
  29. // Note: This code also implements Ctrl+C and Ctrl+Break handlers
  30. // when using the debug option. These console events cause
  31. // your ServiceStop routine to be called
  32. //
  33. // Also, this code only handles the OWN_SERVICE service type
  34. // running in the LOCAL_SYSTEM security context.
  35. //
  36. // To control your service ( start, stop, etc ) you may use the
  37. // Services control panel applet or the NET.EXE program.
  38. //
  39. // To aid in writing/debugging service, the
  40. // SDK contains a utility (MSTOOLS\BIN\SC.EXE) that
  41. // can be used to control, configure, or obtain service status.
  42. // SC displays complete status for any service/driver
  43. // in the service database, and allows any of the configuration
  44. // parameters to be easily changed at the command line.
  45. // For more information on SC.EXE, type SC at the command line.
  46. //
  47. #ifndef _SERVICE_H
  48. #define _SERVICE_H
  49. #ifdef __cplusplus
  50. extern "C" {
  51. #endif
  52. //////////////////////////////////////////////////////////////////////////////
  53. //// todo: change to desired strings
  54. ////
  55. // name of the executable
  56. #define SZAPPNAME "RelStat"
  57. // internal name of the service
  58. #define SZSERVICENAME "RelstatRPCService"
  59. // displayed name of the service
  60. #define SZSERVICEDISPLAYNAME "Relstat RPC Service"
  61. // list of service dependencies - "dep1\0dep2\0\0"
  62. #define SZDEPENDENCIES "RPCSS\0\0"
  63. //////////////////////////////////////////////////////////////////////////////
  64. //////////////////////////////////////////////////////////////////////////////
  65. //// todo: ServiceStart()must be defined by in your code.
  66. //// The service should use ReportStatusToSCMgr to indicate
  67. //// progress. This routine must also be used by StartService()
  68. //// to report to the SCM when the service is running.
  69. ////
  70. //// If a ServiceStop procedure is going to take longer than
  71. //// 3 seconds to execute, it should spawn a thread to
  72. //// execute the stop code, and return. Otherwise, the
  73. //// ServiceControlManager will believe that the service has
  74. //// stopped responding
  75. ////
  76. VOID ServiceStart(DWORD dwArgc, LPTSTR *lpszArgv);
  77. VOID ServiceStop();
  78. //////////////////////////////////////////////////////////////////////////////
  79. //////////////////////////////////////////////////////////////////////////////
  80. //// The following are procedures which
  81. //// may be useful to call within the above procedures,
  82. //// but require no implementation by the user.
  83. //// They are implemented in service.c
  84. //
  85. // FUNCTION: ReportStatusToSCMgr()
  86. //
  87. // PURPOSE: Sets the current status of the service and
  88. // reports it to the Service Control Manager
  89. //
  90. // PARAMETERS:
  91. // dwCurrentState - the state of the service
  92. // dwWin32ExitCode - error code to report
  93. // dwWaitHint - worst case estimate to next checkpoint
  94. //
  95. // RETURN VALUE:
  96. // TRUE - success
  97. // FALSE - failure
  98. //
  99. BOOL ReportStatusToSCMgr(DWORD dwCurrentState, DWORD dwWin32ExitCode, DWORD dwWaitHint);
  100. //
  101. // FUNCTION: AddToMessageLog(LPTSTR lpszMsg)
  102. //
  103. // PURPOSE: Allows any thread to log an error message
  104. //
  105. // PARAMETERS:
  106. // lpszMsg - text for message
  107. //
  108. // RETURN VALUE:
  109. // none
  110. //
  111. void AddToMessageLog(LPTSTR lpszMsg);
  112. //////////////////////////////////////////////////////////////////////////////
  113. #ifdef __cplusplus
  114. }
  115. #endif
  116. #endif