Inno Setup:RegQueryStringValue 不起作用
使用 Inno Setup,我尝试检查 Windows 计算机上是否安装了 .NET 4.8 运行时。如果未安装,我将运行 .NET 4.8 运行时安装程序 exe 文件。 根据Microsoft,您可以检查某个位置的注册表并查看某个值来查看安装了哪个特定版本的 .NET。 Inno Setup 有一个名为 RegQueryStringValue
的函数,它从注册表中获取一个值:
https://jrsoftware.org/ishelp/index.php?topic=isxfunc_regquerystringvalue
据我所知,我正在正确遵循该 API。我还使用 regedit 确认此注册表项和值确实存在于我的系统上。但是,当我运行 Inno Setup 时,它无法找到注册表值。这是我的代码:
function IsDotnet48Installed: boolean;
var
valueStr: string;
valueInt: integer;
begin
if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full', 'Release', valueStr) then
begin
MsgBox('.NET 4.8 registry value is: "' + valueStr + '"', mbInformation, MB_OK);
valueInt := StrToInt(valueStr);
if valueInt >= 528040 then
result := true
else
result := false
end
else
MsgBox('Unable to find .NET 4.8 registry key', mbInformation, MB_OK);
end;
运行上述代码时,RegQueryStringValue
函数返回 false,因此我收到消息框,显示“无法找到 .NET 4.8 注册表项”。我不确定我做错了什么。
谢谢。
Using Inno Setup, I'm trying to check to see if the .NET 4.8 runtime is installed on a Windows computer. If it is not installed, I run the .NET 4.8 runtime installer exe file. According to Microsoft, you can check the registry at a certain location and look at a certain value to see which specific version of .NET is installed. Inno Setup has a function called RegQueryStringValue
which grabs a value from the registry:
https://jrsoftware.org/ishelp/index.php?topic=isxfunc_regquerystringvalue
I am following that API correctly, as far as I'm aware. I have also confirmed, using regedit, that this registry key and value do exist on my system. However, when I run Inno Setup, it fails to find the registry value. Here is my code:
function IsDotnet48Installed: boolean;
var
valueStr: string;
valueInt: integer;
begin
if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full', 'Release', valueStr) then
begin
MsgBox('.NET 4.8 registry value is: "' + valueStr + '"', mbInformation, MB_OK);
valueInt := StrToInt(valueStr);
if valueInt >= 528040 then
result := true
else
result := false
end
else
MsgBox('Unable to find .NET 4.8 registry key', mbInformation, MB_OK);
end;
When the above code is ran, the RegQueryStringValue
function returns false, and I thus get the message box that says "Unable to find .NET 4.8 registry key". I am not sure what I am doing wrong.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
@LexiLi 对原始问题的评论就是答案。
我没有使用函数
RegQueryStringValue
,而是使用了函数RegQueryDWordValue
。第一次尝试就成功了。https://jrsoftware.org/ishelp/index.php?topic=isxfunc_regquerydwordvalue
@LexiLi 's comment to the original question is the answer.
Instead of using the function
RegQueryStringValue
I used the functionRegQueryDWordValue
. Worked on the first try.https://jrsoftware.org/ishelp/index.php?topic=isxfunc_regquerydwordvalue