您的位置:首页 > 编程语言 > Delphi

delphi使用winlicense授权

2015-07-05 15:32 543 查看
unit Unit2;interfaceusesWinapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, WinlicenseSDK, SecureEngineSDK;typeTForm2 = 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;varForm2: TForm2;implementation{$R *.dfm}procedure TForm2.CheckClick(Sender: TObject);beginif WLRegNormalKeyCheck(PAnsiChar(AnsiString(memo1.Text))) = false  thenMessageBox(0, 'The key that you entered is invalid. Please, try it again', 'Error', MB_OK or MB_ICONERROR)elsebegin// if activation is valid, insert the registration info in a file// So, winlicense will be able to finish the registration processWLRegNormalKeyInstallToFile(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);varName : 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;beginEncodeStart();WLHardwareGetID(MachineId);HardwareIdEdit.Text := MachineId;if WLRegGetStatus(ExtStatus) = 1 thenbeginWLRegGetLicenseInfo(Name, Company, ExtraData);NameEdit.Text := Name;CompanyEdit.Text := Company;ExtradataEdit.Text := ExtraData;end;EncodeEnd();end;end.
程序编译之后依赖winlicense的dll需要使用winlicense加壳在能运行。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: