【发布时间】:2021-05-18 21:58:25
【问题描述】:
我想在安装过程中使用代码变量来决定[Icons] 和[Run] 部分,但我不知道我是否错了。
我的[Code] 部分是:
[Code]
var
myW7Val: string;
function GetMyW7Val(Value: string): string;
begin
Result := myW7Val;
end;
function IsWindowsVersionOrNewer(Major, Minor: Integer): Boolean;
var
Version: TWindowsVersion;
begin
GetWindowsVersionEx(Version);
Result :=
(Version.Major > Major) or
((Version.Major = Major) and (Version.Minor >= Minor));
end;
function IsWindows8OrNewer: Boolean;
begin
Result := IsWindowsVersionOrNewer(6, 2);
if not Result then
myW7Val := '1';
myW7Val := '0';
end;
function InitializeSetup: Boolean;
begin
IsWindows8OrNewer
Result := True;
end;
我的[Icons] 部分是:
[Icons]
#if "{code:GetMyW7Val}" == '0'
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; \
Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; \
Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon
#elif "{code:GetMyW7Val}" == '1'
Name: "{autoprograms}\{#MyAppLanceurName}"; \
Filename: "{app}\{#MyAppLanceurExeName}"
Name: "{autodesktop}\{#MyAppLanceurName}"; \
Filename: "{app}\{#MyAppLanceurExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppLanceurName}"; \
Filename: "{app}\{#MyAppLanceurExeName}"; Tasks: quicklaunchicon
#endif
如果 myW7Val 是 0 ,我想使用前三个条目,如果 myW7Val 是 1 ,则使用其他条目。但目前我有一个错误,没有价值观。
你有什么想法吗?
提前致谢
【问题讨论】: