(2011-12-29 11:54:56)
reproduced
Tags:innosetupit |
Category: Development tools Experience accumulation |
Inno Setup before installing the program, if there is a process in use that is running, there will be an error, which makes installer unable to write. Similarly, before uninstalling the program, if a process is still running, there will be an error, and then the uninstallation is not clean and needs to be cleaned manually. So, as long as you check and close the running process before you install the program or uninstall the program, there is no problem. [Code]
//Pre-installation check off * * ProcessProcedure
curstepchanged(curstep:tsetupstep); var appwnd:hwnd;begin if curstep = Ssinstall then BEGIN//check if the XX process is running, then close the process appwnd: = F Indwindowbywindowname (' Process window name '); if (appwnd <> 0) THEN begin PostMessage (Appwnd, 18, 0, 0); Quit end; End;end;
//Check off before uninstalling * * ProcessProcedure
curuninstallstepchanged(curuninstallstep:tuninstallstep); var appwnd:hwnd;begin//Check if the process is running, then close the process appwnd: = findwindowbywindowname (' Process window Name '); if (appwnd <> 0) THEN begin PostMessage (Appwnd, 18, 0, 0); Quit End;end; Of these, Pascal provides two functions to find the process window:
FindwindowbyclassnameAnd
Findwindowbywindowname, the former is based on the class name, which is based on the window name to find the top-level window handle that matches it. You can turn on the process and use the Spy + + tool to get the window name or class name for the process.
Inno Setup checks and closes the running process before Setup starts and before the uninstaller starts