代码之家  ›  专栏  ›  技术社区  ›  user285594

Inno设置-如何在线验证序列号

  •  4
  • user285594  · 技术社区  · 7 年前

    setup.exe

    如何进行设置。由innosetup执行的exe限制为从开始到现在?

    [Setup]
    #define SerialNumber "2017"
    UserInfoPage=yes
    
    [Code]
    function CheckSerial(Serial: String): Boolean;
    begin
      Result := Serial = '{#SerialNumber}';
    end;
    
    • 设置。exe已执行
    • 插入许可证密钥
    • 提交后,我想检查URL https://www.example.com/query/license?id=2017
    1 回复  |  直到 2 年前
        1
  •  3
  •   Martin Prikryl    3 年前

    从以下代码开始: 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 either 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";
    }
    

    enter image description here


    • 这种验证不难绕过,即使用代理服务器。
    • 它也不会阻止用户从安装程序中提取文件并手动安装。
    • 或者下载应用程序运行所需的一些许可文件。无论如何,如果您想强制应用程序在许可证到期后停止工作,您需要这样做。

    • Read Inno Setup encryption key from Internet instead of password box


    How to store serial numbers in a Sharepoint List, for to call from Inno Setup and verify if is autorized user?