Solved

Restarting Application

Posted on 2004-04-28
4
421 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

914 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

19 Experts available now in Live!

Get 1:1 Help Now