如何使用inno-setup在安装过程中检查特定注册表项是否存在并据此退出安装设置?

2026-04-10 16:482阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计515个文字,预计阅读时间需要3分钟。

如何使用inno-setup在安装过程中检查特定注册表项是否存在并据此退出安装设置?

我尝试简化并改写您提供的代码开头内容如下:

我尝试制作安装文件,用于修复以前版本的程序。需要设置检查是否已安装以前程序的功能。这是无法使用的代码。[代码]function GetHKLM(): Integer;begin if IsWin64 then begin Result :=HKLM64; end else begin Result :=Resul

我尝试制作安装文件以修补以前的程序.设置必须能够检查是否安装了以前的程序.

这是我无法使用的代码

[Code] function GetHKLM() : Integer; begin if IsWin64 then begin Result := HKLM64; end else begin Result := HKEY_LOCAL_MACHINE; end; end; function InitializeSetup(): Boolean; var V: string; begin if RegKeyExists(GetHKLM(), 'SOFTWARE\ABC\Option\Settings') then MsgBox('please install ABC first!!',mbError,MB_OK); end;

我的病情是

>必须检查RegKeyExists的32位或64位窗口
>如果未安装以前的程序,则显示错误消息并退出安装程序,否则继续进程.

如何修改代码?
先感谢您.

**更新修复Wow6432Node问题.我尝试修改我的代码

[Code] function InitializeSetup: Boolean; begin // allow the setup to continue initially Result := True; // if the registry key based on current OS bitness doesn't exist, then... if IsWin64 then begin if not RegKeyExists(HKLM, 'SOFTWARE\Wow6432Node\ABC\Option\Settings') then begin // return False to prevent installation to continue Result := False; // and display a message box MsgBox('please install ABC first!!', mbError, MB_OK); end else if not RegKeyExists(HKLM, 'SOFTWARE\ABC\Option\Settings' then begin // return False to prevent installation to continue Result := False; // and display a message box MsgBox('please install ABC first!!', mbError, MB_OK); end end; end; 问题中更新的代码是错误的 – 除了在RegEdit中查看路径之外,你永远不应该使用Wow6432Node.

从您描述的行为来看,您实际上正在寻找一个32位应用程序.在这种情况下,无论Windows是32位还是64位,您都可以使用相同的代码;你是在思考原来的问题.

以下是更新后的问题中的更正代码:

如何使用inno-setup在安装过程中检查特定注册表项是否存在并据此退出安装设置?

[Code] function InitializeSetup: Boolean; begin // allow the setup to continue initially Result := True; if not RegKeyExists(HKLM, 'SOFTWARE\ABC\Option\Settings') then begin // return False to prevent installation to continue Result := False; // and display a message box MsgBox('please install ABC first!!', mbError, MB_OK); end; end;

本文共计515个文字,预计阅读时间需要3分钟。

如何使用inno-setup在安装过程中检查特定注册表项是否存在并据此退出安装设置?

我尝试简化并改写您提供的代码开头内容如下:

我尝试制作安装文件,用于修复以前版本的程序。需要设置检查是否已安装以前程序的功能。这是无法使用的代码。[代码]function GetHKLM(): Integer;begin if IsWin64 then begin Result :=HKLM64; end else begin Result :=Resul

我尝试制作安装文件以修补以前的程序.设置必须能够检查是否安装了以前的程序.

这是我无法使用的代码

[Code] function GetHKLM() : Integer; begin if IsWin64 then begin Result := HKLM64; end else begin Result := HKEY_LOCAL_MACHINE; end; end; function InitializeSetup(): Boolean; var V: string; begin if RegKeyExists(GetHKLM(), 'SOFTWARE\ABC\Option\Settings') then MsgBox('please install ABC first!!',mbError,MB_OK); end;

我的病情是

>必须检查RegKeyExists的32位或64位窗口
>如果未安装以前的程序,则显示错误消息并退出安装程序,否则继续进程.

如何修改代码?
先感谢您.

**更新修复Wow6432Node问题.我尝试修改我的代码

[Code] function InitializeSetup: Boolean; begin // allow the setup to continue initially Result := True; // if the registry key based on current OS bitness doesn't exist, then... if IsWin64 then begin if not RegKeyExists(HKLM, 'SOFTWARE\Wow6432Node\ABC\Option\Settings') then begin // return False to prevent installation to continue Result := False; // and display a message box MsgBox('please install ABC first!!', mbError, MB_OK); end else if not RegKeyExists(HKLM, 'SOFTWARE\ABC\Option\Settings' then begin // return False to prevent installation to continue Result := False; // and display a message box MsgBox('please install ABC first!!', mbError, MB_OK); end end; end; 问题中更新的代码是错误的 – 除了在RegEdit中查看路径之外,你永远不应该使用Wow6432Node.

从您描述的行为来看,您实际上正在寻找一个32位应用程序.在这种情况下,无论Windows是32位还是64位,您都可以使用相同的代码;你是在思考原来的问题.

以下是更新后的问题中的更正代码:

如何使用inno-setup在安装过程中检查特定注册表项是否存在并据此退出安装设置?

[Code] function InitializeSetup: Boolean; begin // allow the setup to continue initially Result := True; if not RegKeyExists(HKLM, 'SOFTWARE\ABC\Option\Settings') then begin // return False to prevent installation to continue Result := False; // and display a message box MsgBox('please install ABC first!!', mbError, MB_OK); end; end;