简体   繁体   English

InnoSetup - 如何要求用户键入许可证密钥或产品密钥并将该代码与编译常量匹配?

[英]InnoSetup - how to ask user to type license key or product key and match that code with compiled constant?

I have to distribute a setup.exe made using innoSetup, where per user and per PC it has to be licensed. 我必须分发使用innoSetup制作的setup.exe,其中每个用户和每台PC必须获得许可。

I was thinking to give them a license key/product key like Windows 8.1 which they have to type in the InnoSetup. 我想给他们一个许可证密钥/产品密钥,如Windows 8.1,他们必须在InnoSetup中输入。 and match it with embedded constant or live over internet. 并将其与嵌入式常量或互联网相匹配。 Once the validation is done then the setup.exe will be complete else it wont install. 验证完成后,setup.exe将完成,否则它将不会安装。

Is there any sample for such with innosetup, how can i do that please? 对于innosetup有没有这样的样品,我该怎么办呢?

To create a page for entering serial numbers you can enable the UserInfoPage directive and write a handler for the CheckSerial event: 要创建用于输入序列号的页面,可以启用UserInfoPage指令并为CheckSerial事件编写处理程序:

#define SerialNumber "123456"

[Setup]
AppName=My Program
AppVersion=1.5
UserInfoPage=yes
DefaultDirName={pf}\My Program

[Code]
function CheckSerial(Serial: String): Boolean;
begin
  Result := Serial = '{#SerialNumber}';
end;

INVALID Serial: INVALID系列:
在此输入图像描述

VALID Serial: VALID系列:
在此输入图像描述

I have used a preprocessor defined constant because that allows you to simplify the build process. 我使用了预处理器定义的常量,因为它允许您简化构建过程。 You can then define such constant from outside the script, with extended command line compiler and make eg a batch script that will build the setup with a defined serial number. 然后,您可以使用extended command line compiler从脚本外部定义此类常量,并制作例如将使用定义的序列号构建设置的批处理脚本。

You would just remove the first (hardcoded) line from the above script and run a command line like this (for serial number 654321 ): 您只需从上面的脚本中删除第一行(硬编码)并运行如下命令行(序列号654321 ):

iscc "/dSerialNumber=654321" "C:\Script.iss"

Of course in real you will need to take care about administration of the output setup files and their serial numbers but the system that you choose is upon you. 当然,实际上您需要注意输出设置文件及其序列号的管理,但您选择的系统就在您身上。 Command line compiler allows you to specify the output path and a file name which is more than enough to build such system. Command line compiler允许您指定输出路径和文件名,这足以构建此类系统。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM