使用Inno Setup,setup.exe
已经给了客户,根据合同他只允许使用2016年和2017年。但是在01-01-2018他不应该继续使用相同的2017年序列号。
如何使innosetup的setup.exe限制为来自和迄今为止?
[Setup]
#define SerialNumber "2017"
UserInfoPage=yes
[Code]
function CheckSerial(Serial: String): Boolean;
begin
Result := Serial = '{#SerialNumber}';
end;
https://www.stackoverflow.com/query/license?id=2017
答案 0 :(得分:2)
从以下代码开始:Inno Setup - HTTP request - Get www/web content,您将得到类似的内容:
[Setup]
UserInfoPage=yes
[Code]
{ Presence of the CheckSerial event function displays the serial number box. }
{ But here we accept any non-empty serial. }
{ We will validate it only in the NextButtonClick, }
{ as the online validation can take long. }
function CheckSerial(Serial: String): Boolean;
begin
Result := (Serial <> '');
end;
function NextButtonClick(CurPageID: Integer): Boolean;
var
WinHttpReq: Variant;
Url: string;
begin
Result := True;
if CurPageID = wpUserInfo then
begin
WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
Url := 'https://www.example.com/serial.php?serial=' +
WizardForm.UserInfoSerialEdit.Text;
WinHttpReq.Open('GET', Url, False);
WinHttpReq.Send('');
{ Depending on implementation of the server, use wither HTTP status code (.Status) or }
{ contents of returned "page" (.ResponseText) }
{ Here we use the HTTP status code: }
{ 200 = serial is valid, anything else = serial is invalid, }
{ and when invalid, we display .ResponseText }
Result := (WinHttpReq.Status = 200);
if not Result then
MsgBox(WinHttpReq.ResponseText, mbError, MB_OK);
end;
end;
一个简单的服务器端验证PHP脚本(serial.php
)就像:
<?
if (empty($_REQUEST["serial"]) || ($_REQUEST["serial"] != "2017"))
{
header("HTTP/1.0 401 The serial number is not valid");
// error message to be displayed in installer
echo "The serial number is not valid";
}
考虑: