Search code examples
delphirestart

Close and restart the current application in DELPHI


How can I do this one?

For some reason or selected by the user, “ask” the current application to restart it self.


Solution

  • uses ShellAPI;
    
    ...
    
    procedure TForm1.RestartThisApp;
    begin
      ShellExecute(Handle, nil, PChar(Application.ExeName), nil, nil, SW_SHOWNORMAL);
      Application.Terminate; // or, if this is the main form, simply Close;
    end;