Para que tu aplicacion sea un servicio inicia un nuevo proyecto asi:
File -> New -> Other -> Service Application
Este será el aspecto:
Código Delphi
[-]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, SvcMgr, Dialogs;
type
TService1 = class(TService)
private
public
function GetServiceController: TServiceController; override;
end;
var
Service1: TService1;
implementation
{$R *.DFM}
procedure ServiceController(CtrlCode: DWord); stdcall;
begin
Service1.Controller(CtrlCode);
end;
function TService1.GetServiceController: TServiceController;
begin
Result := ServiceController;
end;
end.
Ahora tienes que implementar tú los métodos:
Código Delphi
[-]
procedure ServiceStart(Sender: TService; var Started: Boolean);
procedure ServiceStop(Sender: TService; var Stopped: Boolean);
Me imagino que querrás que realice cada cierto tiempo una acción. Pues no puedes poner un Timer así por las buenas. Debes crearlo:
Código Delphi
[-]
.
.
.
private
Timer: TTimer;
.
.
.
Y al comenzar el servicio:
Código Delphi
[-]
procedure ServiceStart(Sender: TService; var Started: Boolean);
begin
Timer:=TTimer.Create(nil);
Timer.Interval := Intervalo;
Timer.OnTimer:=TimerOnTimer; end;
Y al terminar el servicio:
Código Delphi
[-]
procedure ServiceStop(Sender: TService; var Stopped: Boolean);
begin
Timer.Free;
Timer:=nil;
end;
Bueno esto es mas o menos el trabajo. Espero que te ayude.