Running Service Continuously – Delphi

Advertisements

My service does not seem to continuously run.

procedure TService1.ServiceExecute(Sender: TService);
begin
While not Terminated do
  ServiceThread.ProcessRequests(True);
end;

This is what I currently have that is suppose to be keeping the service running, but it does not do so.

>Solution :

This bit of code only runs when the service is started from the Windows Service Manager. Once you have your service .exe file, use a command prompt to start it with the /install command line argument, and use net start <your-service-name> or the Service Management dailog from the Administrative Tools from the Start Menu or Control Panel to start the service.

If you want to run the service in the Delphi debugger, start Delphi with administrative privileges and attach to the running process. But it’s more advisable to have all logic in separate units, and have a separate version of the project as a ‘plain exe’ the run the project’s procedures that you can run in the debugger.

Leave a ReplyCancel reply