...immediately start a service after its installation?

Author: Chris Böhm

Category: System

{ To automatically start a service after its installation use this code }

procedure TMyService.ServiceAfterInstall(Sender: TService);
var
  
sm: TServiceManager;
begin
  
sm := TServiceManager.Create;
  try
    if 
sm.Connect then
      if 
sm.OpenServiceConnection(self.name) then
        
sm.StartService;
  finally
    
sm.Free;
  end;
end;

 

printed from
www.swissdelphicenter.ch
developers knowledge base