Inno: If the detection program is installed, the uninstall prompt pops up.
less frivolous | release:
2010-08-05 | update:
2013-09-05 | Category:
Deployment | Disposition | Heat:
2816 ℃
Implementation principle:Probe the unload item in registry HKEY_LOCAL_MACHINE, ' Software\microsoft\windows\currentversion\uninstall (that is, "Add/Remove Programs") and, if detected, initiates the Uninstall Confirmation dialog box. In practice, you need to modify the "{86d79f54-e485-4011-83fe-ffc558f3db86}" in the code above into the AppID in your own script.
Basic: Whether the test program is installedWhen we use Inno Setup to package, we sometimes want to do something like this: The installer automatically detects if it is already installed, or it pops up the uninstall prompt, otherwise it will install normally. Here is the code snippet:
01 |
function InitializeSetup():boolean; |
03 |
MykeynotExist:boolean; |
08 |
if RegQueryStringValue(HKEY_LOCAL_MACHINE, ‘SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{86D79F54-E485-4011-83FE-FFC558F3DB86}_is1‘ , ‘UninstallString‘ , uicmd) then |
10 |
MyKeynotExist:= false ; |
11 |
Exec(RemoveQuotes(uicmd), ‘‘ , ‘‘ , SW_SHOW, ewWaitUntilTerminated, ResultCode); |
13 |
Result:= MykeynotExist |
|
extension: Two detection system is installed target programFirst detect whether the system has installed the official program, if installed, pop up a message box, when click "OK" automatically start the official program uninstall function. If the official program is not detected, then check whether the program has already been installed, if installed, then directly start the uninstall program, if not detected, the program began to install. The purpose of this is to prevent software conflicts by installing this program without uninstalling the official program.
01 |
function InitializeSetup():boolean; |
03 |
MykeynotExist:boolean; |
08 |
if RegQueryStringValue(HKEY_LOCAL_MACHINE, ‘SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{B7F653CF-1BE5-4F40-BA4A-E3BBC6869116}‘ , ‘UninstallString‘ , uicmd) then |
10 |
MyKeynotExist:= false ; |
11 |
MsgBox( ‘安装程序检测到您的系统中已经安装了官方的 {#AppName} ‘ #10#10 ‘你最好先卸载此 {#AppName} 再安装本 {#AppName}‘ ,mbInformation,MB_OK) |
12 |
Exec(ExpandConstant( ‘{pf}\InstallShield Installation Information\{{B7F653CF-1BE5-4F40-BA4A-E3BBC6869116}\Setup.exe‘ ), ‘‘ , ‘‘ , SW_Show, ewNoWait, ResultCode); |
14 |
Result:= MykeynotExist |
15 |
if RegQueryStringValue(HKEY_LOCAL_MACHINE, ‘SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{49D79F54-D485-4011-83FE-FFC938F3DB86}_is1‘ , ‘UninstallString‘ , uicmd) then |
17 |
MyKeynotExist:= false ; |
18 |
Exec(RemoveQuotes(uicmd), ‘‘ , ‘‘ , SW_SHOW, ewWaitUntilTerminated, ResultCode); |
20 |
Result:= MykeynotExist |
|
Inno: If the detection program is installed, the uninstall prompt pops up.