Jump to content
uniGUI Discussion Forums
NelZ

Kill application, recompile and auto start in browser

Recommended Posts

Hi,

 

Everytime we recompile application, you must close in traybar and refresh browser page.

The tip will automatically close application and start a new page in default browser.

 

In Project, Options, Build Events,Pre-Build, write command:

  taskkill /F /IM program.exe /T

procedure TUniServerModule.UniGUIServerModuleCreate(Sender: TObject);
begin
  if self.StandAloneServer then //if you need this, if not, remove it.
    ExploreWeb('http://localhost:8077'); //auto start browser
end;

procedure ExploreWeb(page:PChar);
var Returnvalue: integer;
begin
  ReturnValue := ShellExecute(0, 'open', page, nil, nil,SW_SHOWNORMAL);
  if ReturnValue <= 32 then
     begin
     case Returnvalue of
          0 : MessageBox(0,'Error: Out of memory','Error',0);
          ERROR_FILE_NOT_FOUND: MessageBox(0,'Error: File not found','Error',0);
          ERROR_PATH_NOT_FOUND: MessageBox(0,'Error: Directory not found','Error',0);
          ERROR_BAD_FORMAT    : MessageBox(0,'Error: Wrong format in EXE','Error',0);
     else
          MessageBox(0,PChar('Error Nr: '+IntToStr(Returnvalue)+' inShellExecute'),'Error',0)
     end;
  end;
end;

 

procedure TFMainForm.UniFormShow(Sender: TObject);
begin

    //show frame/form to login only if we are not debuging...

    if  (DebugHook = 0) then
    begin
      FLogin.ShowModal;

     ...

    end;

end;

  • Upvote 4

Share this post


Link to post
Share on other sites

my  project name is one8077 ,the exe is one8077.exe.

 

Why show "[Exec Error] The command "taskkill /F /IM one8077.exe /T" exited with code 128."?

Hi

 

En Project Options -> Build Events -> Pre-Build Events -> Cancel on Error = False.

 

 

 

  • Upvote 1

Share this post


Link to post
Share on other sites

Hi,

 

Which edition and build are you using?

 

Best regards,

Share this post


Link to post
Share on other sites

Trial Edition

But another exe not unigui app i can't kill before compile

 

Sorry on Delphi Xe 3 Windows 7  work fine

But Delphi Rad Tokiyo 10.2.2  OS Windows 10 can't kill task by RAD 10.2.2 pre build command

if this command run cmd .exe   "taskkill /F /IM test.exe /T"  Tasks killed all

Share this post


Link to post
Share on other sites

Project options -> Build evebts -> Pre-Builds events -> Commands =

call C:\xxxxx\uniGUI.cmd $(OUTPUTFILENAME)

"uniGUI.cmd" text file in:

start taskkill /F /IM firefox.exe /T
start taskkill /F /IM %1 /T

Share this post


Link to post
Share on other sites

I found what problem before run I need change something like move button or change caption like this

after that compilled and run task will kill..

 

In RAD XE3 work everytime when pushing RUN without changing something  but RAD Tokiyo  need change something before run second time

Share this post


Link to post
Share on other sites

Hi

 

En Project Options -> Build Events -> Pre-Build Events -> Cancel on Error = False.

 

Worked for me!

Thank you.

Share this post


Link to post
Share on other sites

×