I hopefully have a quick question: is it possible to delay ShellExecute execution a bit?
I have an application with autoupdater. After downloading all the necessary files, etc. It renames the current files to * .OLD, and the new one as the previous one. Simple enough. But then I need to delete these .OLD files. This "cleanup" procedure is performed on MainForm.OnActivate (checking if this is the first proc activation). But this seems to be happening too fast (I get False from DeleteFile). This is the procedure:
procedure TUpdateForm.OKBtnClick(Sender: TObject); const SHELL = 'ping 127.0.0.1 -n 2'; begin ShellExecute(0,'open',pchar(SHELL+
This procedure should restart the application. I am sure that the removal problem was caused by the quick launch of the second application, because if I restart it myself, giving it a little time, the files will be deleted normally.
tl; dr : I need to call ShellExecute (), which is waiting for a bit (0.1 s or so), and THEN will execute the command.
Note
I tried using the -ping command to try to delay it, but that didn't work.
Thank you in advance
Edit: rephrase
I need this to happen || The first application closes; Wait 100 ms; the second application opens || I need to call ShellExecute first, and then wait for the calling application to close completely, and then start the shell (i.e. open the second application)
delphi shellexecute delay
Martin Melka
source share