delphi使用winlicense授权



unit Unit2;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, WinlicenseSDK, SecureEngineSDK;

type
  TForm2 = class(TForm)
    Memo1: TMemo;
    Check: TButton;
    NameEdit: TEdit;
    CompanyEdit: TEdit;
    ExtradataEdit: TEdit;
    HardwareIdEdit: TEdit;
    procedure CheckClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.CheckClick(Sender: TObject);
begin
    if WLRegNormalKeyCheck(PAnsiChar(AnsiString(memo1.Text))) = false  then

        MessageBox(0, 'The key that you entered is invalid. Please, try it again', 'Error', MB_OK or MB_ICONERROR)

    else
    begin

      // if activation is valid, insert the registration info in a file
      // So, winlicense will be able to finish the registration process

      WLRegNormalKeyInstallToFile(PAnsiChar(AnsiString(memo1.Text)));

      MessageBox(0, 'Registration key is correct. Please, restart this application to finish the registration process', 'Success', MB_OK);

    end;
end;

procedure TForm2.FormCreate(Sender: TObject);
var

  Name : ARRAY[0..200] of AnsiChar;
  Company : ARRAY[0..200] of AnsiChar;
  ExtraData : ARRAY[0..200] of AnsiChar;
  MachineId: ARRAY [0..100] of AnsiChar;
  ExtStatus: Integer;
begin
    EncodeStart();
    WLHardwareGetID(MachineId);
    HardwareIdEdit.Text := MachineId;
   if WLRegGetStatus(ExtStatus) = 1 then
    begin

        WLRegGetLicenseInfo(Name, Company, ExtraData);
        NameEdit.Text := Name;
        CompanyEdit.Text := Company;
        ExtradataEdit.Text := ExtraData;

    end;
    EncodeEnd();
end;

end.
程序编译之后依赖winlicense的dll需要使用winlicense加壳在能运行。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值