Solved

Restarting Application

Posted on 2004-04-28
4
420 Views
Last Modified: 2010-04-05
How can i fully restart my application using simple code?
0
Comment
Question by:tomerlei
4 Comments
 
LVL 22

Accepted Solution

by:
Ferruccio Accalai earned 25 total points
ID: 10938536
uses shellapi
procedure TForm1.Button1Click(Sender: TObject);
begin;
application.Terminate;
Shellexecute(0,'',PCHar(paramstr(0)),'','',sw_ShowNormal);
end;

or
uses windows

application.Terminate;
winexec(PCHar(paramstr(0)),sw_ShowNormal);
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10938541
uses ShellApi;

procedure AppRestart;
var AppName : PChar;
begin
  AppName := PChar(Application.ExeName) ;
  ShellExecute(Handle,'open', AppName, nil, nil, SW_SHOWNORMAL) ;
  Application.Terminate;
end;
0
 
LVL 17

Expert Comment

by:mokule
ID: 10939719
You should better use

  Application.Terminate;
  WinExec(CmdLine,SW_SHOWNORMAL);

which also passes command line parameters.
0
 
LVL 2

Expert Comment

by:-Karamja-
ID: 10941530
procedure TForm1.Button1Click(Sender: TObject);
var
  FullProgPath: PChar;
begin
  FullProgPath := PChar(Application.ExeName);
  WinExec(FullProgPath, SW_SHOW); // Or better use the CreateProcess function
  Application.Terminate; // or: Close;
end;
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now