gpt4 book ai didi

inno-setup - 根据条件写入注册表

转载 作者:行者123 更新时间:2023-12-04 00:46:35 28 4
gpt4 key购买 nike

我想根据操作系统写入注册表。我有操作系统检测功能,发现您可以在注册表部分放置一个检查功能,所以尝试了以下操作:

Root: HKLM; SubKey: Software\Microsoft\Windows; ValueType: dword; ValueName: Test; ValueData: 1; Flags: createvalueifdoesntexist; Check: IsWindows7

但它没有用,意味着当我在 Win7 和 WinXP 上安装时,它在这两种情况下都将值写入注册表。

这是检测操作系统的代码:

function IsWindows7(): Boolean;
var
Version: TWindowsVersion;
begin
GetWindowsVersionEx(Version);

// Windows 7 version is 6.1 (workstation)
if (Version.Major = 6) and
(Version.Minor = 1) and
(Version.ProductType = VER_NT_WORKSTATION)
then
Result := True
else
Result := False;
end;

有什么想法/建议吗?

最佳答案

请参阅下面我为您提供的解决方案:

[Registry]

Root: HKLM; SubKey: {code:IsWindows7}; ValueType: dword; ValueName: Test; ValueData: 1; Flags: createvalueifdoesntexist; Check: IsWindows7

[Code]

function IsWindows7(S: String) : string;
var
Version: TWindowsVersion;
begin

GetWindowsVersionEx(Version);

// Windows 7 version is 6.1 (workstation)
if (Version.Major = 6) and
(Version.Minor = 1) and
(Version.ProductType = VER_NT_WORKSTATION)
then
Result := '<registry path for win 7>'
else
Result := '<registry path for other win os >';

end;

编码愉快!

关于inno-setup - 根据条件写入注册表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8982469/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com