Leaked source code of windows server 2003
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.

76 lines
1.7 KiB

  1. // Copyright (c) 1997-1999 Microsoft Corporation
  2. //
  3. // Service Control Manager wrapper class
  4. //
  5. // 10-6-98 sburns
  6. #ifndef SERVICE_HPP_INCLUDED
  7. #define SERVICE_HPP_INCLUDED
  8. // Simple NTService Control Manager wrapper
  9. class NTService
  10. {
  11. public:
  12. // Constructs a new instance that corresponds to the given service name on
  13. // the given computer.
  14. //
  15. // machine - name of the computer. Empty string corresponds to the local
  16. // computer.
  17. //
  18. // serviveName - name of the service.
  19. NTService(const String& machine, const String& serviceName);
  20. // Constructs a new instance that corresponds to the given service name on
  21. // the local computer (the machine on which this call is invoked).
  22. //
  23. // serviveName - name of the service.
  24. explicit
  25. NTService(const String& serviceName);
  26. ~NTService();
  27. bool
  28. IsInstalled();
  29. // Queries the SCM for the last reported state of the service.
  30. HRESULT
  31. GetCurrentState(DWORD& state);
  32. // Uses GetCurrentState in a loop with sleeps until the service
  33. // enters the specified state or until the timeout period has passed
  34. HRESULT
  35. WaitForServiceState(
  36. DWORD state,
  37. DWORD sleepInterval = DEFAULT_SLEEP_INTERVAL,
  38. DWORD timeout = DEFAULT_TIMEOUT);
  39. // These defaults were taken from the filemgmt snapin which
  40. // provides the start/stop services UI
  41. static const DWORD DEFAULT_SLEEP_INTERVAL = 500;
  42. static const DWORD DEFAULT_TIMEOUT = DEFAULT_SLEEP_INTERVAL * 250;
  43. private:
  44. // not implemented: no copying allowed
  45. NTService(const NTService&);
  46. const NTService& operator=(const NTService&);
  47. String machine;
  48. String name;
  49. };
  50. #endif // SERVICE_HPP_INCLUDED