?
Solved

Restarting Application

Posted on 2004-04-28
4
Medium Priority
?
430 Views
Last Modified: 2010-04-05
How can i fully restart my application using simple code?
0
Comment
Question by:tomerlei
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 23

Accepted Solution

by:
Ferruccio Accalai earned 100 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses
Course of the Month14 days, 17 hours left to enroll

770 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