Inno设置Regkeyexists返回false,尽管密钥存在

发布于 2025-02-11 00:21:23 字数 614 浏览 2 评论 0原文

有人可以告诉我这个代码怎么了?

[Code]
const
  OldVersionRegKey = '\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#MyAppId}_is1';
 
var
  HasOldVersion: Boolean;
 
function GetKey : Integer;
begin
  if IsWin64 then
    Result := HKLM64
  else
    Result := HKLM32;
end;
 
procedure CheckOldVersion;
begin
  HasOldVersion := RegKeyExists(GetKey, OldVersionRegKey);
  // ...
end;

因为无论我做什么,答案都是false,而键确实存在?

我已经尝试了所有内容,关键不在错误结果寄存器中,关键在于错误结果寄存器中,在数据库的不同级别,在32位数据库上,在64位数据库上,根据架构进行测试(就像当前的代码一样),但无事可做,结果总是相同的。

预先感谢您的帮助。

Can someone tell me what is wrong with this code?

[Code]
const
  OldVersionRegKey = '\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#MyAppId}_is1';
 
var
  HasOldVersion: Boolean;
 
function GetKey : Integer;
begin
  if IsWin64 then
    Result := HKLM64
  else
    Result := HKLM32;
end;
 
procedure CheckOldVersion;
begin
  HasOldVersion := RegKeyExists(GetKey, OldVersionRegKey);
  // ...
end;

Because whatever I do the answer is False while the key does exist?

I have tried everything, the key is not in the false result register, the key is in the false result register, on different levels of the database, on the 32 bit database, on the 64 bit database, test on both depending on the architecture (like the current code), but nothing to do, the result and always the same.

Thank you in advance for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猛虎独行 2025-02-18 00:21:23

关键路径的开头不应斜线。检查

const
  OldVersionRegKey = 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#MyAppId}_is1';

而且由于您不使用 64-bit安装模式 hklm32 。

HasOldVersion := RegKeyExists(HKLM32, OldVersionRegKey);

或者,如果您希望脚本与64位安装模式兼容,请使用 is64bitinstallMode ,而不是iswin64

There should be no slash at the beginning of the key path. Check the example in RegKeyExists documentation.

const
  OldVersionRegKey = 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#MyAppId}_is1';

And as you are not using 64-bit install mode, the root key is always HKLM32.

HasOldVersion := RegKeyExists(HKLM32, OldVersionRegKey);

Or, if you want the script to be compatible with 64-bit install mode, use Is64BitInstallMode, instead of IsWin64.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文