只允许 运行 Inno Setup 安装程序一次

Allow running Inno Setup installer only once

我想将我的软件的一些免费副本提供给某些用户,但我想防止 Inno Setup 安装程序也在其他计算机上 运行。所以我希望安装程序在一台计算机上只 运行 一次,然后再也不会。

制作在线服务,安装程序将检查以确定是否允许安装。该服务应计算安装次数并做出相应响应。

function InitializeSetup(): Boolean;
var
  WinHttpReq: Variant;
begin
  Result := False;

  Log('Checking installation online...');
  try
    WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
    WinHttpReq.Open('GET', 'https://www.example.com/install_check.php', false);
    WinHttpReq.Send();
    if WinHttpReq.Status = 200 then
    begin
      Log('Installation was allowed...');
      Result := True;
    end
      else
    begin
      Log(Format('Installation was not allowed with %d: %s...', [
        WinHttpReq.Status, WinHttpReq.StatusText]));
      MsgBox('Installation is not allowed.', mbError, MB_OK);      
    end;
  except
    Log(Format('Installation check failed: %s', [GetExceptionMessage]));
    MsgBox('Error checking if the installation is allowed.', mbError, MB_OK);      
  end;
end;

一个简单的服务器端验证 PHP 脚本 (install_check.php) 就像:

<?

$flag_file = "/data/install_check";
if (file_exists($flag_file))
{
    $msg = "This installer was already installed";
    header("HTTP/1.0 401 $msg");
    echo $msg;
}
else
{
    echo "Can install";
    touch($flag_file);
}

相关问题:


虽然从 Inno Setup 安装程序中提取文件很容易。您可以通过加密安装并从在线服务中检索解密密码来改进它。

通过不返回密码,您将有效地阻止安装。

Read Inno Setup encryption key from Internet instead of password box