INNO setup制作安装包实现一机一码安装包

2025-09-27 11:51:44

1、根据百度网盘链接下载此版本inno setup安装,然后制作软件包时在代码处setup加入UserInfoPage=true,并复制以下代码到code段,自行修改生成机器码数字不然算法通用,如下图

var HDSerial: LongInt;

function GetVolumeInformation(    lpRootPathName: PChar;    lpVolumeNameBuffer: PChar;    nVolumeNameSize: LongInt;    var lpVolumeSerialNumber: LongInt;    lpMaximumComponentLength: LongInt;    lpFileSystemFlags : LongInt;    lpFileSystemNameBuffer: PChar;    nFileSystemNameSize: LongInt ) : Integer;external 'GetVolumeInformationA@kernel32.dll stdcall';

function GetLastError( ): Integer;external 'GetLastError@kernel32.dll stdcall';

function GenMachineID(SerialNum: LongInt): String;var SN: LongInt; MID, tmp1, tmp2: string;begin// 生成机器码数字处请自行修改  if SerialNum > 532178923 then    SN:= SerialNum-532178923  else    SN:= 532178923-SerialNum;  tmp1:= IntToStr(SN);  while length(tmp1)>3 do    begin    tmp2:= copy(tmp1,1,3);    delete(tmp1,1,3);    MID:= MID+Chr(65+StrToInt(tmp2)*26/999)+tmp2;    end;  MID:= MID+Chr(65+StrToInt(tmp1)*26/999)+tmp1;  tmp1:= MID;  MID:= '';  while length(tmp1)>3 do    begin    tmp2:= copy(tmp1,1,3);    delete(tmp1,1,3);    MID:= MID+tmp2+'-';    end;  MID:= MID+tmp1;  If SerialNum > 532178923 then    MID:='6J7-'+MID  else    MID:='V94-'+MID;result:= MID;end;

function GenRegCode(SerialNum: LongInt): String;var MID,tmp1,tmp2: string;   SN: LongInt;begin// 生成注册码  if SerialNum > 537698023 then    SN:= SerialNum-537698023  else    SN:= 537698023-SerialNum;  MID:='';  tmp1:= IntToStr(SN);  while length(tmp1)>3 do    begin    tmp2:= copy(tmp1,1,3);    delete(tmp1,1,3);    MID:= MID+Chr(65+StrToInt(tmp2)*26/999)+tmp2;    end;  MID:= MID+Chr(65+StrToInt(tmp1)*26/999)+tmp1;  tmp1:= MID;  MID:= '';  while length(tmp1)>3 do    begin    tmp2:= copy(tmp1,1,3);    delete(tmp1,1,3);    MID:= MID+tmp2+'-';    end;  MID:= MID+tmp1;  If SerialNum > 537698023 then    MID:='3P6-'+MID  else    MID:='X5B-'+MID;result:= MID;end;

procedure InitializeWizard();begin WizardForm.USERINFOSERIALLABEL.top := WizardForm.USERINFOORGLABEL.top+        2*(WizardForm.USERINFOORGLABEL.top - WizardForm.USERINFONAMELABEL.top); WizardForm.USERINFOSERIALEDIT.top := WizardForm.USERINFOORGEDIT.top+        2*(WizardForm.USERINFOORGEDIT.top - WizardForm.USERINFONAMEEDIT.top); WizardForm.USERINFOSERIALLABEL.Font.Color := clblack;end;

procedure curpagechanged(curpage: integer);var IDLabel, RegAdr, RegURL: TLabel; IDEdit: TEdit; RefDisk, DiskLabel: String;beginif curpage=wpUserInfo then begin    if DirExists('C:\') then      RefDisk:= 'C:\'    else      RefDisk:= 'D:\';  DiskLabel:= '                ';  GetVolumeInformation(RefDisk, DiskLabel, 15, HDSerial, 0, 0, '', 0);

  IDLabel:= TLabel.Create(WizardForm);  IDLabel.parent:= WizardForm.USERINFONAMELABEL.parent;  IDLabel.top:= WizardForm.USERINFONAMELABEL.top+        2*(WizardForm.USERINFOORGLABEL.top - WizardForm.USERINFONAMELABEL.top);  IDLabel.left:= WizardForm.USERINFOSERIALLABEL.left;  IDLabel.autosize:= true;  IDLabel.font.color:= clblack;  IDLabel.caption:= '机器码:';

  RegAdr:= TLabel.Create(WizardForm);  RegAdr.parent:= WizardForm.USERINFONAMELABEL.parent;  RegAdr.top:= WizardForm.USERINFOSERIALLABEL.top+    (WizardForm.USERINFOORGLABEL.top - WizardForm.USERINFONAMELABEL.top)-7;  RegAdr.left:= WizardForm.USERINFOSERIALLABEL.left + 220;  RegAdr.autosize:= true;  RegAdr.caption:= '注册请联系:XXXXXX;

  IDEdit:= TEdit.Create(WizardForm);  IDEdit.parent:= WizardForm.USERINFONAMEEDIT.parent;  IDEdit.top:= WizardForm.USERINFONAMEEDIT.top+        2*(WizardForm.USERINFOORGEDIT.top - WizardForm.USERINFONAMEEDIT.top);  IDEdit.left:= WizardForm.USERINFOSERIALEDIT.left;  IDEdit.width:= WizardForm.USERINFOSERIALEDIT.width;  IDEdit.readonly:= true;  IDEdit.color:= clGray;  IDEdit.text := GenMachineID(HDSerial); end;end;

function CheckSerial(Serial: string): Boolean;begin result:= (Serial=GenRegCode(HDSerial)) or (UpperCase(Serial)='WWW.HANZIFY.ORG');end;

INNO setup制作安装包实现一机一码安装包

INNO setup制作安装包实现一机一码安装包

2、注册机制作可以通过直接编辑界面打造个性化,代码如下,注意如果前面改了生成机器码数字后面也要对应进行修改否则算法不一致算出注册码无效,好了界面可以通过此版本直接进行编辑自行美化。教程到这里结束,写的有点乱,将就看吧

[Setup]AppName=xx注册机AppVerName=xx注册机CreateAppDir=noDisableProgramGroupPage=yesDefaultGroupName=xxUserInfoPage=trueOutputBaseFilename=注册机OutputDir=.

[Messages]UserInfoName=机器码:UserInfoORg=硬件码:UserInfoSerial=注册码:WizardUserInfo=HRV注册机UserInfoDesc=输入注册码程序将自动计算出注册码。

BeveledLabel=xxxSetupAppTitle=注册机SetupWindowTitle=xxx注册机

[Code]{ RedesignWizardFormBegin } // 不要删除这一行代码。// 不要修改这一段代码,它是自动生成的。var  NewButton1: TNewButton;  Label1: TLabel;  Label2: TLabel;  Label3: TLabel;  OldEvent_UserInfoNameEditChange: TNotifyEvent;  NewButton2: TNewButton;  Panel4: TPanel;  Label4: TLabel;  OldEvent_CancelButtonClick: TNotifyEvent;

procedure NewButton1Click(Sender: TObject); forward;procedure UserInfoNameEditChange(Sender: TObject); forward;procedure NewButton2Click(Sender: TObject); forward;procedure _CancelButtonClick(Sender: TObject); forward;

procedure RedesignWizardForm;begin  with WizardForm do  begin    Caption := 'xx注册机';    AutoScroll := False;    ClientHeight := ScaleY(192);    ClientWidth := ScaleX(299);  end;

  { NewButton1 }  NewButton1 := TNewButton.Create(WizardForm);  with NewButton1 do  begin    Parent := WizardForm.WelcomePage;    Left := ScaleX(304);    Top := ScaleY(144);    Width := ScaleX(81);    Height := ScaleY(25);    Caption := 'NewButton1';    OnClick := @NewButton1Click;  end;

  NewButton1.TabOrder := 2;

  with WizardForm.InnerPage do  begin    Cursor := crHand;    Color := clSilver;  end;

  with WizardForm.Bevel1 do  begin    Left := ScaleX(392);    Top := ScaleY(66);    Width := ScaleX(435);  end;

  { Label1 }  Label1 := TLabel.Create(WizardForm);  with Label1 do  begin    Parent := WizardForm.InnerPage;    Caption := '机器码:';    Transparent := False;    Left := ScaleX(56);    Top := ScaleY(88);    Width := ScaleX(42);    Height := ScaleY(12);  end;

  { Label2 }  Label2 := TLabel.Create(WizardForm);  with Label2 do  begin    Parent := WizardForm.InnerPage;    Caption := '机器码:';    Transparent := False;    Left := ScaleX(0);    Top := ScaleY(88);    Width := ScaleX(42);    Height := ScaleY(12);  end;

  { Label3 }  Label3 := TLabel.Create(WizardForm);  with Label3 do  begin    Parent := WizardForm.InnerPage;    Caption := '注册码:';    Transparent := False;    Left := ScaleX(0);    Top := ScaleY(120);    Width := ScaleX(42);    Height := ScaleY(12);  end;

  with WizardForm.LicenseLabel1 do  begin    Left := ScaleX(200);    Top := ScaleY(136);  end;

  with WizardForm.UserInfoPage do  begin    Color := clSilver;  end;

  with WizardForm.UserInfoSerialLabel do  begin    Caption := '注册码:';    Left := ScaleX(304);    Top := ScaleY(120);    Width := ScaleX(49);    Height := ScaleY(12);  end;

  with WizardForm.UserInfoOrgEdit do  begin    Left := ScaleX(376);    Top := ScaleY(48);    Width := ScaleX(0);    Visible := False;  end;

  with WizardForm.UserInfoNameLabel do  begin    Caption := '';    FocusControl := nil    Left := ScaleX(264);    Width := ScaleX(153);  end;

  with WizardForm.UserInfoOrgLabel do  begin    Caption := '';    Left := ScaleX(416);    Top := ScaleY(70);    Width := ScaleX(65);  end;

  with WizardForm.UserInfoNameEdit do  begin    Left := ScaleX(8);    Top := ScaleY(16);    Width := ScaleX(169);    OldEvent_UserInfoNameEditChange := OnChange;    OnChange := @UserInfoNameEditChange;  end;

  with WizardForm.UserInfoSerialEdit do  begin    Left := ScaleX(8);    Top := ScaleY(48);    Width := ScaleX(169);  end;

  { NewButton2 }  NewButton2 := TNewButton.Create(WizardForm);  with NewButton2 do  begin    Parent := WizardForm.UserInfoPage;    Left := ScaleX(184);    Top := ScaleY(16);    Width := ScaleX(57);    Height := ScaleY(52);    Caption := '退出';    OnClick := @NewButton2Click;  end;

  NewButton2.TabOrder := 6;

  with WizardForm.MainPanel do  begin    Height := ScaleY(44);    Color := cl3DLight;  end;

  with WizardForm.PageDescriptionLabel do  begin    Left := ScaleX(8);    Top := ScaleY(19);    Height := ScaleY(13);  end;

  with WizardForm.PageNameLabel do  begin    AutoSize := True;    Visible := False;    Left := ScaleX(280);    Top := ScaleY(-15);    Width := ScaleX(8);  end;

  { Panel4 }  Panel4 := TPanel.Create(WizardForm);  with Panel4 do  begin    Parent := WizardForm.InnerPage;    Left := ScaleX(0);    Top := ScaleY(152);    Width := ScaleX(417);    Height := ScaleY(57);    Color := cl3DLight;    ParentBackground := False;  end;

  { Label4 }  Label4 := TLabel.Create(WizardForm);  with Label4 do  begin    Parent := Panel4;    Caption := '版权所有:xxx';    Transparent := False;    Left := ScaleX(8);    Top := ScaleY(8);    Width := ScaleX(102);    Height := ScaleY(12);  end;

  Panel4.TabOrder := 2;

  with WizardForm.CancelButton do  begin    Left := ScaleX(337);    Top := ScaleY(446);    OldEvent_CancelButtonClick := OnClick;    OnClick := @_CancelButtonClick;  end;

{ ReservationBegin }  // 这一部分是提供给你的,你可以在这里输入一些补充代码。

{ ReservationEnd }end;// 不要修改这一段代码,它是自动生成的。{ RedesignWizardFormEnd } // 不要删除这一行代码。

procedure UserInfoNameEditChange(Sender: TObject);begin  OldEvent_UserInfoNameEditChange(Sender);end;

procedure NewButton2Click(Sender: TObject);beginOldEvent_CancelButtonClick(Sender);end;

procedure NewButton1Click(Sender: TObject);beginOldEvent_CancelButtonClick(Sender);end;

procedure _CancelButtonClick(Sender: TObject);begin  OldEvent_CancelButtonClick(Sender);end;

var HDSN: LongInt;

function getSerialCode(HDSN: LongInt): string;var MID,tmp1,tmp2: string;SN: LongInt;begin// 生成注册码SaveStringToFile('E:\1122.txt', 'HDSN: '+ IntToStr(HDSN)+#13#10, true);if HDSN > 537698023 thenSN:= HDSN-537698023elseSN:= 537698023-HDSN;SaveStringToFile('E:\1122.txt', 'SN: '+ IntToStr(SN)+#13#10, true);MID:='';tmp1:= IntToStr(SN);while length(tmp1)>3 dobegintmp2:= copy(tmp1,1,3);delete(tmp1,1,3);MID:= MID+Chr(65+StrToInt(tmp2)*26/999)+tmp2;end;MID:= MID+Chr(65+StrToInt(tmp1)*26/999)+tmp1;SaveStringToFile('E:\1122.txt', 'SC: '+ MID+#13#10, true);tmp1:= MID;MID:= '';while length(tmp1)>3 dobegintmp2:= copy(tmp1,1,3);delete(tmp1,1,3);MID:= MID+tmp2+'-';end;MID:= MID+tmp1;SaveStringToFile('E:\1122.txt', 'SC: '+ MID+#13#10, true);If HDSN > 537698023 thenMID:='3P6-'+MIDelseMID:='X5B-'+MID;result:= MID;SaveStringToFile('E:\1122.txt', 'SC: '+ MID+#13#10, true);end;

function getregcode(MID: string): string;var SN,tmp1,tmp2: string;numSN: LongInt;begin// 注册码SaveStringToFile('E:\1122.txt', 'MID: '+ MID+#13#10, false);tmp1 := MID;delete(tmp1,1,4);SN:= '';while length(tmp1)>4 dobegintmp2:= copy(tmp1,1,3);delete(tmp1,1,4);SN:= SN+tmp2;end;if tmp1 > '' thenSN:= SN+tmp1;SaveStringToFile('E:\1122.txt', 'SN: '+ SN +#13#10, true);tmp1:= SN;SN:= '';while length(tmp1)>4 dobegintmp2:= copy(tmp1,2,3);delete(tmp1,1,4);SN:= SN+tmp2;end;if tmp1 > '' thenbegindelete(tmp1,1,1);SN:= SN+tmp1;end;SaveStringToFile('E:\1122.txt', 'SN: '+ SN +#13#10, true);numSN := StrToIntDef(SN, 0);If StrGet(MID,1) = '6' thennumSN := numSN + 532178923elsenumSN:= 532178923 - numSN;//HDSN:= numSN;SaveStringToFile('E:\1122.txt', 'HDSN: '+ IntToStr(numSN)+#13#10, true);result:= getSerialCode(numSN);SaveStringToFile('E:\1122.txt', 'RegCode: '+ result +#13#10, true);end;

procedure InitializeWizard();varyn: Integer;begin  RedesignWizardForm;yn := WizardForm.UserInfoNameEdit.Top;WizardForm.UserInfoNameEdit.Top := WizardForm.UserInfoSerialEdit.Top;WizardForm.UserInfoSerialEdit.Top := yn;WizardForm.UserInfoNameEdit.ReadOnly:= true;WizardForm.UserInfoOrgEdit.ReadOnly:= true;WizardForm.UserInfoNameEdit.Text:= '';WizardForm.UserInfoOrgEdit.Text:= '';WizardForm.UserInfoSerialEdit.Text:= '<请输入机器码>';WizardForm.UserInfoSerialEdit.TabOrder:= 0;end;

  procedure CurPageChanged(CurPageID: Integer);beginif CurPageID = wpWelcome thenWizardForm.NextButton.OnClick(WizardForm);end;

procedure CancelButtonClick(CurPageID : Integer; var Cancel, Confirm: Boolean);beginConfirm := false;end;

function CheckSerial(Serial: string): Boolean;beginresult:= false;if (Copy(Serial,1,3)= 'V94') or (Copy(Serial,1,3)= '6J7') thenbeginWizardForm.USERINFONAMEEDIT.text := GetRegCode(Serial);WizardForm.USERINFOORGEDIT.text := IntToStr(HDSN);endelsebeginWizardForm.USERINFONAMEEDIT.text := '-';WizardForm.USERINFOORGEDIT.text := '<请忽略此项>';end;end;

INNO setup制作安装包实现一机一码安装包

INNO setup制作安装包实现一机一码安装包

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢