title: Delphi XE Service won't start: Error 1053
body: <p>I have a service made in Delphi XE that will not start when prompted from the service manager in Windows 7, I get</p>
  
  <pre><code>Error 1053: The service did not respond to the start or control reqquest in a timely fashion
  </code></pre>
  
  <p>I have the service hooked up with an AfterInstall and an OnExecute event, here is my code for the events:</p>
  
  <pre><code>procedure TAarhusRunner.ServiceAfterInstall(Sender: TService);
  var
    Reg: TRegistry;
  begin
    Reg := TRegistry.Create(KEY_READ or KEY_WRITE);
    try
  
      Reg.RootKey := HKEY_LOCAL_MACHINE;
      if Reg.OpenKey('\SYSTEM\CurrentControlSet\Services\' + Name, false) then
      begin
        Reg.WriteString('Description', 'Worker Service for Inversion Job Distribution');
        Reg.CloseKey;
      end;
    finally
      Reg.Free;
    end;
  end;
  
  procedure TAarhusRunner.ServiceExecute(Sender: TService);
  begin
    try
      Self.Status := csRunning;
  
      //start the loop
      MainTimer.Interval := 5000; //MainTimer is declared in the .dfm
      MainTimer.Enabled := True;
      RecheckAndApplyTimer.Enabled := False;
      while not Terminated do
      begin
         ServiceThread.ProcessRequests(true);
         MainTimer.Enabled := False;
      end;
  
    except
      on e: Exception do begin
        MessageDlg(E.Message,mterror,[mbok],0);
        exit;
      end;
    end;
  end;
  </code></pre>
  
  <p>Can anyone tell me what I am doing wrong?</p>