home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 June (DVD) / DPPRO0605DVD.iso / Install / program files / Borland / BDS / 3.0 / Demos / Delphi.Net / CLR / WindowsService / Service.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2004-10-22  |  1.9 KB  |  95 lines

  1. unit Service;
  2. //------------------------------------------------------------------------------
  3. //  File name:      Service.pas
  4. //  Last updated:   11/9/03
  5. //  Author:         Sergey Mishkovskiy
  6. //  Company:        USysWare, Inc.
  7. //  Contact info:   usysware@comcast.net
  8. //
  9. //  Compatibility:  Borland Delphi for .NET
  10. //
  11. //  Description:    Consists of TWindowsService class that implements base 
  12. //                  .NET service class.
  13. //------------------------------------------------------------------------------
  14.  
  15. interface
  16.  
  17. uses
  18.   System.ServiceProcess;
  19.  
  20. type
  21.   TWindowsService = class(System.ServiceProcess.ServiceBase)
  22.   strict protected
  23.     procedure OnStart(args: array of string); override;
  24.     procedure OnPause; override;
  25.     procedure OnStop; override;
  26.     procedure OnContinue; override;
  27.     procedure OnShutdown; override;
  28.   public
  29.     constructor Create;
  30.   end;
  31.  
  32. var
  33.   WindowsService: TWindowsService = nil;
  34.  
  35. implementation
  36.  
  37. uses
  38.   ProjectInstaller;
  39.  
  40. { TWindowsService }
  41.  
  42. constructor TWindowsService.Create;
  43. begin
  44.   inherited Create;
  45.  
  46.   ServiceName := DefaultServiceName;
  47.  
  48.   CanHandlePowerEvent := False;
  49.   CanPauseAndContinue := True;
  50.   CanShutdown := True;
  51.   CanStop := True;
  52.  
  53.   EventLog.Source := DefaultServiceName;
  54.   EventLog.Log := ''; //ToDo: set your custom log or leave it blank for defaults
  55.  
  56.   AutoLog := True;
  57. end;
  58.  
  59. procedure TWindowsService.OnStart(args: array of string);
  60. begin
  61.   inherited;
  62.  
  63.   //ToDo: add your code here
  64. end;
  65.  
  66. procedure TWindowsService.OnPause;
  67. begin
  68.   inherited;
  69.  
  70.   //ToDo: add your code here
  71. end;
  72.  
  73. procedure TWindowsService.OnStop;
  74. begin
  75.   inherited;
  76.  
  77.   //ToDo: add your code here
  78. end;
  79.  
  80. procedure TWindowsService.OnContinue;
  81. begin
  82.   inherited;
  83.  
  84.   //ToDo: add your code here
  85. end;
  86.  
  87. procedure TWindowsService.OnShutdown;
  88. begin
  89.   inherited;
  90.  
  91.   //ToDo: add your code here
  92. end;
  93.  
  94. end.
  95.