4
I just implemented a Windows service I just can’t get it to turn automatically when the windows is started. I don’t know if it was some thing in the programming or some configuration of the windows. I also found nothing on this subject made with Delphi here.
Code in service
procedure ServiceController(CtrlCode: DWord); stdcall;
begin
SvcAutoPub.Controller(CtrlCode);
end;
function TSvcAutoPub.GetServiceController: TServiceController;
begin
Result := ServiceController;
end;
procedure TSvcAutoPub.ServiceExecute(Sender: TService);
begin
Timer.Enabled := True;
while not Terminated do
ServiceThread.ProcessRequests(True); // fica em looping até alguém fechar o serviço
Timer.Enabled := False;
end;
procedure TSvcAutoPub.ServiceStart(Sender: TService; var Started: Boolean);
begin
if Connection.Connected = False then
begin
try
Connection.Connected := True;
finally
tbParametos.Open;
tbProcessos.Open;
tbPublicacoes.Open;
tbPonteiros.Open;
tbAndamentos.Open;
tbClientes.Open;
end;
end;
end;
The Properties of the Service: If it is some windows configuration there I no longer where goes.
You registered your service in the OS? Installutil.exe
– Augusto Vasques
yes it works good only no auto start
– Edu Mendonça
It appears in the service list and the settings shows the option to start automatically?
– Augusto Vasques
Sure if I had to install the service
– Edu Mendonça
I used this command to install the service "PATH_COMPLETO_DO_SERVION /INSTALL".
– Edu Mendonça
I haven’t forgotten about you, I’m reading the documentation. But I’m finding difficulties and finding quality material for Delphi.
– Augusto Vasques
I already have 2 weeks looking and nothing...
– Edu Mendonça
I found nothing about it at the moment. I’ll keep looking if I find anything I leave an answer.
– Augusto Vasques
Blz, thank you very much!
– Edu Mendonça
It starts manually if Voce is going to start it on the list if services?
– Tiago Rodrigues
Yes. When I open the list of services it is already there only stopped I have to press to start.
– Edu Mendonça
As soon as possible I will be bringing an answer that will possibly solve your problem. At the moment I am far from my computer.
– Matheus Ribeiro
@Mendonça the solution that I presented does not solve? Here it is perfectly running automatically.
– Junior Moreira
I don’t know what it is... I did the installation as @Jefferson Rudolf spoke and did as you said it runs when windows opens only it starts with the status stopped
– Edu Mendonça
But you started it a first time? In my answer I put:
de um start nele faça seus testes se o serviço esta executando
– Junior Moreira
it performs yes only it comes with statos stopped. are you understanding? sabe la na services appears initializing, stopping and restarting mine as when windows start it starts the service stopped even there in Delphi i setting for automatic. I have to go into service and press start for it to work.
– Edu Mendonça