通过代码将卸载注册表项设置为条件 [英] Make the uninstall registry key conditional via code

查看:76
本文介绍了通过代码将卸载注册表项设置为条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过以下方法使Inno Setup禁用 CreateUninstallRegKey 代码?

How do you make Inno Setup disable CreateUninstallRegKey via code?

我在Inno Setup中创建的 setup.exe 文件接受参数,例如:

My setup.exe file created in Inno Setup accepts parameters, e.g.:

setup.exe -a

setup.exe -b

如果提供了-a参数,则启用CreateUninstallRegKey;如果提供了-b参数,则禁用CreateUninstallRegKey.

If -a parameter is supplied, then enable CreateUninstallRegKey, or if -b parameter is supplied, then disable CreateUninstallRegKey.

反正是通过代码设置CreateUninstallRegKey还是我必须先创建一个函数然后在脚本部分中调用该函数?

Is there anyway to set CreateUninstallRegKey via code or do I have to make a function then call the function in script section?

帮助页面说明了有关使用{code:...}常量的信息,但不幸的是,我遇到了此错误:

This help page explains about using {code:...} constants, but unfortunately I got this error:

谢谢

推荐答案

请勿使用{code:}表达式将值传递给布尔类型指令.这样做:

Do not use the {code:} expression for passing values to Boolean type directives. Do it this way:

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
CreateUninstallRegKey=NeedsUninstallRegKey

[Code]
function CmdLineParamExists(const Value: string): Boolean;
var
  I: Integer;  
begin
  Result := False;
  for I := 1 to ParamCount do
    if CompareText(ParamStr(I), Value) = 0 then
    begin
      Result := True;
      Exit;
    end;
end;

function NeedsUninstallRegKey: Boolean;
begin
  Result := CmdLineParamExists('-a');
end;

这篇关于通过代码将卸载注册表项设置为条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆