Use installshield to obtain the registry, delete the registry, and determine the installed version.

Source: Internet
Author: User

When installing the installation package, you often encounter updates and other problems. When Using installshield to create the installation package, if the software version changes, the update is automatically completed. However, we have a problem here. If the regist information of the new version and the regist information of the old version are changed in installshield, for example, the Registry structure is changed, or the previous registry directory does not need to be deleted, when running a new installer, the program will inevitably report an error .. This is why when many software versions are installed, he will ask you to delete the original version and continue the installation (at the beginning, my solution was to delete the previously registered dll through scripts, however, it is found that although the dll registration information is deleted, its program is still adding and deleting the installer, so this method is not feasible ). Now I want to explain how to determine whether the previous version is installed and notify the user to delete it.

There is the Product Code option in installshield, which means a specific Product Code to determine whether it is the same software. The following is an old version.

The new Product Code is as follows:

After the Product Code is updated, the upgrade interface will not appear when the installation package is run, but two versions of the software will appear in the machine, this is very impolite for users.

So we want to determine whether the user has installed the previous version and prompts him to delete it. In this case, I found it in the Registry Information and finally found it ..

In HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Uninstall \ {your product Code}, if you have installed your SOFTWARE and have not uninstalled it, this registration information will appear here ..

In this case, the problem is how to detect this registry information during installation and prompt the user to uninstall this version.

Our purpose is to detect and prompt before installation, so we need to write the script in function OnFirstUIBefore. I found a function

RegDBKeyExist ("\ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Uninstall \ {your product Code }");

The value-1 indicates that the registration information is not found, and 1 indicates that the registration information is found.

Before using this function, you need to use this function to determine the root directory for registry operations:

RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE );

After knowing this, our task is basically completed. The code is attached:

RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE); if (RegDBKeyExist ("\ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Uninstall \ {region}")> 0) then MessageBox ("the installation software has detected an earlier version. To ensure that the software is correctly installed, uninstall it. The installation process is coming to an end. ", SEVERE); abort; endif;

In fact, the code is very simple, mainly because the installshield script language is not familiar to everyone, and there is little information on the Internet.

Delete registered function RegDBDeleteKey (string)

I have found a summary of installshield's script language functions. I hope it will help you in your future work!

InstallShield internal library functions

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.