Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 10-07-2025
_Io _Io is offline
Miembro
 
Registrado: ene 2024
Posts: 114
Poder: 3
_Io Va por buen camino
TService , no arranca

Hola, buenas tardes.

He buscado en el foro y se habla mucho de este tema, pero no he sabido encontrar la respuesta de el porqué no arranca.

Este sería el código, más o menos parecido a alguno que he visto en el foro:

Código Delphi [-]
program Project1;

uses
  Vcl.SvcMgr,
  Unit1 in 'Unit1.pas' {Service1: TService};

{$R *.RES}

begin
  if not Application.DelayInitialize or Application.Installing then
    Application.Initialize;
  Application.CreateForm(TService1, Service1);
  Application.Run;
end.


Código Delphi [-]
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.SvcMgr, Vcl.Dialogs,
  extctrls;

type
  TService1 = class(TService)
    procedure ServiceStart(Sender: TService; var Started: Boolean);
    procedure ServiceStop(Sender: TService; var Stopped: Boolean);
  private
    tmr :TTimer;

  private
    procedure Ontimer(Sender: TObject);
    procedure WriteLog(cMsg:String);

  public
    function GetServiceController: TServiceController; override;
    { Public declarations }
  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;


procedure TService1.ServiceStart(Sender: TService; var Started: Boolean);
begin

  beep;

  WriteLog('ServiceStart');

  tmr:=TTimer.Create(nil);
  tmr.Interval:=1000;
  tmr.OnTimer:=Ontimer;
  tmr.Enabled:=true;

  Started:=true;

end;


procedure TService1.ServiceStop(Sender: TService; var Stopped: Boolean);
begin

  beep;

  WriteLog('ServiceStop');

  if assigned(tmr) then
  begin

    tmr.Enabled:=false;
    freeandnil(tmr);

  end;

  Stopped:=true;

end;

procedure TService1.Ontimer(Sender: TObject);
begin

  beep;

  WriteLog('Ontimer');

end;



procedure TService1.WriteLog(cMsg:String);
var
  myFile : TextFile;
  cFile  : string;

begin

  Try
     cFile := 'C:\Users\Papá\Desktop\Desarrollo\Documentos\DOCs\Service_Test.txt';

     AssignFile(myFile, cFile);
     if fileExists(cFile) then
           Append(myfile)
     else
           ReWrite(myFile);

     WriteLn(myFile, FormatDateTime('yyyy-mmm-dd hh:mm:ss',now)+ ' '+ cMsg);

  finally

    CloseFile(myFile);

  end;

end;

end.

¿Podéis ver el motivo?

Muchas Gracias.
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
TService sancarlos API de Windows 4 12-11-2008 10:14:25
TService y TForm Softweb API de Windows 5 20-10-2008 17:41:01
TService, IB, FB OSKR C++ Builder 0 27-04-2005 11:51:11
Imprimir desde un TService gynch Varios 2 02-04-2004 19:35:23
Imprimir desde un TService gynch Impresión 0 24-03-2004 14:12:16


La franja horaria es GMT +2. Ahora son las 10:33:12.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi