delphi使用winlicense授权

来源:互联网 发布:国玺云计算最新消息 编辑:程序博客网 时间:2024/04/29 12:48
unit Unit2;interfaceuses  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 0
原创粉丝点击