unit Service;
interface
uses
System.Drawing, System.Collections, System.ComponentModel, svcmgr,
System.Windows.Forms, System.Data, system.serviceprocess, System.Configuration.Install;
type
[RunInstaller(true)]
TService1 =
class(System.ServiceProcess.ServiceBase)
{$REGION 'Vom Designer verwalteter Code'}
strict private
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
Components: System.ComponentModel.Container;
/// <summary>
/// Erforderliche Methode zur Unterstützung des Designers -
/// ändern Sie die Methode nicht mit dem Quelltext-Editor
/// </summary>
procedure InitializeComponent;
{$ENDREGION}
strict protected
/// <summary>
/// Ressourcen nach der Verwendung bereinigen
/// </summary>
procedure Dispose(Disposing: Boolean);
override;
private
{ Private-Deklarationen }
Timer1 : System.Windows.Forms.Timer;
procedure timer(sender: TObject; e: System.EventArgs);
public
{ Public-Deklarationen }
strict protected
procedure OnStop;
override;
procedure OnStart(args:
array of string);
override;
public
constructor Create;
end;
//
var
Service1: TService1;
// [assembly: RuntimeRequiredAttribute(TypeOf(ServiceBase))]
implementation
uses Main, ccLog;
//{$R *.nfm}
{$AUTOBOX ON}
{$REGION 'Vom Windows Form-Designer erzeugter Code'}
/// <summary>
/// Erforderliche Methode zur Unterstützung des Designers --
/// ändern Sie die Methode nicht mit dem Quelltext-Editor
/// </summary>
procedure TService1.InitializeComponent;
begin
Self.Components := System.ComponentModel.Container.Create;
Self.ServiceName := '
Testdienst';
end;
{$ENDREGION}
procedure TService1.Dispose(Disposing: Boolean);
begin
if Disposing
then
begin
if Components <>
nil then
Components.Dispose();
end;
inherited Dispose(Disposing);
end;
constructor TService1.Create;
begin
inherited Create;
//
// Erforderlich für die Unterstützung des Windows Forms-Designers
//
InitializeComponent;
//
// TODO: Fügen Sie nach dem Aufruf von InitializeComponent Konstruktorcode hinzu.
//
end;
procedure TService1.onstop;
begin
//
end;
procedure TService1.timer(sender: System.
Object; e: System.EventArgs);
begin
addlogtext('
STarte timerevent');
end;
procedure TService1.OnStart(args:
array of string);
begin
Try
Timer1 := System.Windows.Forms.Timer.Create;
Timer1.Interval := 10000;
Include(Self.timer1.Tick, timer);
addlogtext('
Start OnStart');
Main.create;
Except
on e :
Exception Do addlogtext(e.
Message);
end;
addlogtext('
Ende OnStart');
Timer1.Start;
end;
end.