Advertisement
Guest User

Untitled

a guest
Jul 18th, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.ServiceProcess;
  6. using System.Configuration;
  7. using System.Diagnostics;
  8.  
  9. namespace WindowsService
  10. {
  11. class WindowsService : ServiceBase
  12. {
  13.  
  14. public WindowsService()
  15. {
  16.  
  17. //Names the Service and gives log file to write/read from
  18. this.ServiceName = "Windows Service";
  19. this.EventLog.Log = "Application";
  20.  
  21. //Sets the permissions of the service
  22. this.CanHandlePowerEvent = true;
  23. this.CanHandleSessionChangeEvent = true;
  24. this.CanPauseAndContinue = true;
  25. this.CanShutdown = true;
  26. this.CanStop = true;
  27. }
  28.  
  29. static void Main()
  30. {
  31. ServiceBase.Run(new WindowsService()); //Runs the Service
  32. }
  33.  
  34. #region The differenet functions
  35.  
  36. protected override void Dispose(bool disposing) //Disposing
  37. {
  38. base.Dispose(disposing);
  39. }
  40.  
  41. protected override void OnStart(string[] args) //On Start up
  42. {
  43. base.OnStart(args);
  44. }
  45.  
  46. protected override void OnStop() //On Stop
  47. {
  48. base.OnStop();
  49. }
  50.  
  51. protected override void OnPause() //On Pause
  52. {
  53. base.OnPause();
  54. }
  55.  
  56. protected override void OnContinue() //On Continue
  57. {
  58. base.OnContinue();
  59. }
  60.  
  61. protected override void OnShutdown() //On Shut down
  62. {
  63. base.OnShutdown();
  64. }
  65.  
  66. protected override void OnCustomCommand(int command) //On a Custom Command
  67. {
  68. base.OnCustomCommand(command);
  69. }
  70.  
  71. protected override bool OnPowerEvent(PowerBroadcastStatus powerStatus) //On a Power event
  72. {
  73. return base.OnPowerEvent(powerStatus);
  74. }
  75.  
  76. protected override void OnSessionChange(SessionChangeDescription changeDescription) //On a Session change
  77. {
  78. base.OnSessionChange(changeDescription);
  79. }
  80. #endregion
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement