Jump to content

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;

  • Like 1
  • Upvote 4
Link to comment
Share on other sites

  • 3 years later...
  • 2 weeks later...
  • 7 months later...
  • 2 months later...

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
Link to comment
Share on other sites

  • 4 weeks later...

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

Link to comment
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

Link to comment
Share on other sites

  • 5 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...