程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> Windows優化大師注冊機源碼

Windows優化大師注冊機源碼

編輯:Delphi
  unit Unit1;

  interface

  uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Registry, StdCtrls, Buttons;

  type
  TForm1 = class(TForm)
  Label1: TLabel;
  Label2: TLabel;
  Edit1: TEdit;
  Edit2: TEdit;
  Label3: TLabel;
  Edit3: TEdit;
  GetKeySpeedButton: TSpeedButton;
  CheckBox1: TCheckBox;
  Label4: TLabel;
  procedure GetKeySpeedButtonClick(Sender: TObject);
  procedure CheckBox1Click(Sender: TObject);
  private
  { Private declarations }
  public
  { Public declarations }
  end;

  var
  Form1: TForm1;
  Family, Model, Stepping: Byte;

  implementation

  {$R *.dfm}

  //獲得CPU信息的過程,用匯編代碼寫的
  procedure GetCpuID;
  asm
  PUSH EAX
  MOV EAX, 1
  DW $A20F //匯編指令CPUID的機器代碼
  MOV Stepping, AL
  AND Stepping, 0FH //取得CPU STEPPING數送入到變量Stepping中
  AND AL, 0F0H
  SHR AL, 4
  MOV Model, AL //取得CPU MODEL數送入到變量Model中
  SHR AX, 8
  AND AL, 0FH
  MOV Family, AL //取得CPU FAMILYG數送入到變量Family中
  POP EAX
  end;

  //RSA的加密和解密函數,等價於(m^e) mod n(即m的e次冪對n求余)
  function Encrypt_Decrypt(m: Int64; e: Int64=$2C86F9; n: Int64=$69AAA0E3): Int64;
  var
  a, b, c: Int64;
  begin
  a:=m;
  b:=e;
  c:=1;
  while b<>0 do
  if (b mod 2)=0
  then begin
  b:=b div 2;
  a:=(a * a) mod n;
  end
  else begin
  b:=b - 1;
  c:=(a * c) mod n;
  end;
  Result:=c;
  end;

  procedure TForm1.GetKeySpeedButtonClick(Sender: TObject);
  var
  ID, UserName, CpuVer: String;
  s: Array [1..4] of Cardinal;
  temp, Num1, Num2: Cardinal;
  Code1, Code2: Int64;
  i, ascii: Byte;
  Reg: TRegistry;
  begin
  if (Edit1.Text='') and (CheckBox1.Checked=False)
  then Application.MessageBox('請輸入注冊申請碼!', '警告', MB_OK);
  if (Edit1.Text='') and (CheckBox1.Checked=True)
  then Application.MessageBox('請輸入注冊者姓名!', '警告', MB_OK);
  if (CheckBox1.Checked=true) and (Edit1.Text<>'')
  then begin
  UserName:=Edit1.Text; //從Edit1.Text中取得用戶名
  GetCpuID; //調用過程GetCpuID
  CpuVer:='Level '+IntToStr(Family)+' Rev. '+IntToStr(Model)+'.'+IntToStr(Stepping);
  temp:=1;
  i:=1;
  while UserName[i]<>#0 do begin
  ascii:=ord(UserName[i]); //函數ord()的作用為取得字符的ASCII碼
  temp:=(temp*ascii+$D0878) mod $F4240;
  inc(i);
  end;
  i:=1;
  while CpuVer[i]<>#0 do begin
  ascii:=ord(CpuVer[i]);
  temp:=(temp*ascii+$2597D) mod $F4240;
  inc(i);
  end;
  ID:=IntToStr(temp);
  end;
  if (CheckBox1.Checked=false) and (Edit1.Text<>'')
  then ID:=Edit1.Text;
  ID:=ID+'1234567';
  SetLength(ID, 8); //把字符串ID長度變為8個,並把後面的字符截掉

  //下面四行語句是把字符串'You are big pig.'的內存數據送到變量s中
  s[1]:=$20756f59;
  s[2]:=$20657261;
  s[3]:=$20676962;
  s[4]:=$2e676970;
  Num1:=0;
  for i:=4 downto 2 do
  Num1:=(Num1+ord(ID[i])) shl 8;
  Num1:=Num1+ord(ID[1]);
  Num2:=0;
  for i:=8 downto 6 do
  Num2:=(Num2+ord(ID[i])) shl 8;
  Num2:=Num2+ord(ID[5]);
  temp:=0;
  for i:=1 to 32 do begin
  temp:=temp+$9E3779B9;
  Num1:=Num1+(Num2 shl 4)+(s[1] xor Num2)+((Num2 shr 5) xor temp)+s[2];
  Num2:=Num2+(Num1 shl 4)+(s[3] xor Num1)+((Num1 shr 5) xor temp)+s[4];
  end;

  Code1:=(Num1 mod $40000000) + 2;
  Code2:=($93E0014 shl 2)+ Num1 div $40000000 + 2;
  Code1:=Encrypt_Decrypt(Code1);
  code2:=Encrypt_Decrypt(Code2);
  if (CheckBox1.Checked=False) and (Edit1.Text<>'')
  then begin
  Edit2.Text:=IntToHex(Code1, 8);
  Edit3.Text:=IntToHex(Code2, 8);
  end;
  if (CheckBox1.Checked=True) and (Edit1.Text<>'')
  then begin
  Reg:=TRegistry.Create;
  Reg.RootKey:=HKEY_LOCAL_MacHINE;
  if Reg.OpenKey('SoftwareWom', True)
  then begin
  Reg.DeleteValue('Masters');
  Reg.WriteString('Register', UserName);
  Reg.WriteString('Register_1', IntToHex(Code1, 8));
  Reg.WriteString('Register_2', IntToHex(Code2, 8));
  end;
  Reg.Free;
  Application.MessageBox('自動注冊完成!', '信息', MB_OK);
  end;
  end;

  procedure TForm1.CheckBox1Click(Sender: TObject);
  begin
  if CheckBox1.Checked=true
  then begin
  GetKeySpeedButton.Caption:='自動注冊';
  Label1.Caption:='注冊者姓名';
  Edit1.MaxLength:=0;
  Label2.Visible:=false;
  Label3.Visible:=false;
  Edit2.Visible:=false;
  Edit3.Visible:=false;
  end
  else begin
  GetKeySpeedButton.Caption:='取得注冊碼';
  Label1.Caption:='注冊申請碼';
  Edit1.MaxLength:=8;
  Label2.Visible:=true;
  Label3.Visible:=true;
  Edit2.Visible:=true;
  Edit3.Visible:=true;
  end;
  end;

  

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved