Inno: If the detection program is installed, the uninstall prompt pops up.

Source: Internet
Author: User

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: 2816Implementation 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 functionInitializeSetup():boolean;
02 var
03   MykeynotExist:boolean;
04   ResultCode: Integer;
05   uicmd: String;
06 begin
07   MykeynotExist:= true;
08   ifRegQueryStringValue(HKEY_LOCAL_MACHINE, ‘SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{86D79F54-E485-4011-83FE-FFC558F3DB86}_is1‘, ‘UninstallString‘, uicmd) then
09   begin
10   MyKeynotExist:= false;
11   Exec(RemoveQuotes(uicmd), ‘‘, ‘‘, SW_SHOW, ewWaitUntilTerminated, ResultCode);
12   end;
13   Result:= MykeynotExist
14 end;
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 functionInitializeSetup():boolean;
02 var
03   MykeynotExist:boolean;
04   ResultCode: Integer;
05   uicmd: String;
06 begin
07   MykeynotExist:= true;
08   ifRegQueryStringValue(HKEY_LOCAL_MACHINE, ‘SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{B7F653CF-1BE5-4F40-BA4A-E3BBC6869116}‘, ‘UninstallString‘, uicmd) then
09   begin
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);
13   end;
14   Result:= MykeynotExist
15   ifRegQueryStringValue(HKEY_LOCAL_MACHINE, ‘SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{49D79F54-D485-4011-83FE-FFC938F3DB86}_is1‘, ‘UninstallString‘, uicmd) then
16   begin
17   MyKeynotExist:= false;
18   Exec(RemoveQuotes(uicmd), ‘‘, ‘‘, SW_SHOW, ewWaitUntilTerminated, ResultCode);
19   end;
20   Result:= MykeynotExist
21 end;

Inno: If the detection program is installed, the uninstall prompt pops up.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.