INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Execute a programme from delphi that terminates my app

Execute a programme from delphi that terminates my app

(OP)
I wish to be able to update my delphi app on remote machines.

My delphi app "MyApp" performs an ftp to get an update programme "Myupdate" and saves it. "MyUpdate" then needs to run but it needs to replace "MyApp".

Whilst I can get Delphi to shell/execute/run "MyUpdate", I cannot work out how to get "MyUpdate" to terminate "MyApp" in order that it can be replaced with an updated replacement "MyApp" contained in "MyUpdate".

The remote machines have no keyboard/screen/mouse so no user interaction is available. "MyApp" on the remote machine is automatically run on boot/startup. I can send an autorun CD/DVD via mail to update "MyApp" so that it can contain the correct code to run the the "MyUpdate" but the whole idea is to be able to avoid updating "MyApp" via mail with CD's/DVD's.

I could create a "scheduled task" to call "MyUpdate" as part of the next mailed update but wondered if there are other ways.

Many thanks

RE: Execute a programme from delphi that terminates my app

CODE

procedure TForm1.Button1Click(Sender: TObject);
var
  thewnd: HWnd;
begin
  thewnd := FindWindow(nil, 'Dummy App');
  if thewnd <> 0 then
    SendMessage(thewnd, WM_CLOSE, 0, 0);
end; 

'Dummy App' needs to be one with a form that responds to messages, of course. command-line processes, services, etc, will be different.

It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.

RE: Execute a programme from delphi that terminates my app

(OP)
That's fine for closing "MyApp" from another program such as a CD/DVD autorun update but I want the running "MyApp" to load end execute "MyUpdate" which has to close "MyApp" in order to update the MyApp.exe

When I have tried this in the past, the closure of MyApp using the technique in your example also stops MyUpdate as it was initiated by MyApp.

RE: Execute a programme from delphi that terminates my app

I just tried it that way and it works here as I posted above. I can even get it to work just by sliding "Application.Terminate" in after the call to "MyUpdate", which is even more preferable than what I posted above because "MyApp" will terminate itself. "MyUpdate" is the only thing running after the fact.

Granted, Vista, 7, and 8 may work much different than XP in this regard. But from what I'm seeing it looks like you need to post a whole lot more details than what you already have, because it's obvious that you have something else going on if neither approach works right.

It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.

RE: Execute a programme from delphi that terminates my app

(OP)
Many thanks Glenn9999 - I will have some further tries next week and let you know one way or the other how I get on!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close