View Full Version : Closing Applications
greenace
03-09-2005, 02:53 PM
So far I love Version 2! The ability to easily download multiple patch files is great!
I am trying to ensure than my application is closed before processing the patch file. I have tried using the examples for both the Window.EnumerateProcesses and Window.EnumerateTitles and have been unable to get my application to close. In version 1.0, I used the Close Program option, and it worked fine. What am I doing wrong!
I'd preffer to force the program to shut down than prompting the user to close it.
Brett
03-09-2005, 04:28 PM
In our update for TrueUpdate I use the following code:
-- These actions are performed when the Next button is clicked.
function IsProcessRunning(strName)
local tblProcesses = Window.EnumerateProcesses();
local bProcessFound = false;
local nProcessHandle = nil;
if(tblProcesses)then
local strProcessName;
local nHandle;
for nHandle, strProcessName in tblProcesses do
if(String.Find(strProcessName,strName,1,false) ~= -1)then
nProcessHandle = nHandle;
bProcessFound = true;
end
end
end
return bProcessFound;
end
local strMsg = "TrueUpdate is running and must be shut down in order to continue.\r\n";
strMsg = strMsg.."Please shut the application down and click Retry to continue.";
bKeepTrying = IsProcessRunning("TU20Design.exe");
while(bKeepTrying)do
local nRes = Dialog.Message("Notice",strMsg, MB_RETRYCANCEL,MB_ICONEXCLAMATION);
if(nRes == IDCANCEL)then
bKeepTrying = false;
Application.Exit();
else
bKeepTrying = IsProcessRunning("TU20Design.exe");
end
end
However, that requires user interaction, so let's try this:
-- Try and close a names process. Return true if it was closed
-- successfully or false if not.
function CloseProcessIfRunning(strName)
local bProcessClosedSuccessfully = false;
local tblProcesses = Window.EnumerateProcesses();
local bProcessFound = false;
local nProcessHandle = nil;
if(tblProcesses)then
local strProcessName;
local nHandle;
for nHandle, strProcessName in tblProcesses do
if(String.Find(strProcessName,strName,1,false) ~= -1)then
nProcessHandle = nHandle;
bProcessFound = true;
end
end
end
if(bProcessFound and nProcessHandle)then
-- Try a soft close:
Window.Close(nProcessHandle,CLOSEWND_SENDMESSAGE);
if(Application.GetLastError() ~= 0)then
-- Try a hard close:
Window.Close(nProcessHandle,CLOSEWND_TERMINATE);
if(Application.GetLastError() == 0)then
bProcessClosedSuccessfully = true;
end
else
bProcessClosedSuccessfully = true;
end
end
return bProcessClosedSuccessfully;
end
Hope that helps.
greenace
03-09-2005, 09:03 PM
Thats works great! Every time I try something new - I think this new release is even better. What do you think about the possibility of creating some type of Dependency Like code Like SUF 7? The server compnent could easily handle this - then a user could build a small initial installer - that would then execute the full TrueUpdate 2.0 Driven Installation. Perhaps this would better facilitate the "Download Dependency Components" On Demand Concept?
Thanks for the help!
Ted Sullivan
03-09-2005, 09:18 PM
Thanks for the great comments on TrueUpdate 2.0! We're really excited about it too.
We set out to create the most flexible and powerful software updating system available on the market, and keep the price down to a fraction of what Installshield and ZeroG charge for their product. Incidentally, and of course I'm naturally biased, but TrueUpdate 2.0 is head and shoulders above those offerings. There's very little that TrueUpdate 2.0 can't handle!
Brett
03-10-2005, 12:55 AM
What do you think about the possibility of creating some type of Dependency Like code Like SUF 7?
That can certainly be done already. Just look at the script in the SUF70 dependency's properties and use it in TU20. Using this method you can roll your own dependency checking system in no time.
fabian
02-22-2006, 10:49 AM
I'm using your code to close my application and its server. The server is a tray-application which is not visible at runtime. If I try to close the main program (which is visible), it works fine, but when I use the same code to close the tray app., it doesn't work.
Hope you can help me.
Regards,
Fabian van Schevikhoven
CorepaQ Systems
Hi fabian. There has been a pretty hot thread going for a few days in the AMS6 forum on the exact same topic.
http://www.indigorose.com/forums/showthread.php?t=15026
We looked into this one a bit and what everyone is saying is correct. Basically when an application is in the system tray, it becomes a child window of the window with the classname "Shell_TrayWnd". So it's IDs do change and therefore aren't regular top level windows any longer that can be accessed in the same way.
kymaita
02-06-2007, 10:09 AM
Hi
I'm testing TrueUpdate software and I'm just in this Step.
I want to close my application if it is running at the moment an update is available and user press a next button after accepting the license agreement.
I tried this code with a sample windows form application made in .Net 2.0 and it works well but my application is like Messenger application. One feature of my application is that it has timers running in the background and those timers stop the application for closing; maybe because those timers run in separate threads. I need to use a more powerful instruction to dispose the application and all threads associated to it.
What can I do?
Kenny
kymaita
02-09-2007, 10:32 AM
Hi
I found the answer
This instruction does not work for me
Window.EnumerateProcesses();
I was needing
Window.EnumerateProcesses(false);
Because the window of my application is not visible
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.