欢迎使用CSDN-markdown编辑器

来源:互联网 发布:linux lnmp 编辑:程序博客网 时间:2024/06/06 09:00
unit Unit7;interfaceuses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs, ExtCtrls, uMlCustomButton, uMlSkinColorButton,  uMlSkinPasswordEdit, GR32_Image_ml, uMlSkinCtrls, uMlSkinEdit,  uMlSkinPanel, uMlSkinLabel,Registry, uMlSkinAlphaForm, uMlSkinNCCtrlBase,  uMlSkinNCButton, jpeg, uMlStdCtrl, uMlSkinForm, pngimage_ml,clipbrd;type  TForm7 = class(TForm)    edit1: TMlSkinEdit;    MlSkinColorButton1: TMlSkinColorButton;    MlSkinColorButton2: TMlSkinColorButton;    code: TMlSkinEdit;    MlSkinLabel1: TMlSkinLabel;    MlSkinLabel2: TMlSkinLabel;    MlSkinLabel3: TMlSkinLabel;    MlSkinForm1: TMlSkinForm;    MlSkinSystemButton1: TMlSkinSystemButton;    MlSkinAlphaForm1: TMlSkinAlphaForm;    logo: TMlSkinPanel;    Image1: TImage;    MlSkinColorButton3: TMlSkinColorButton;    procedure MlSkinColorButton1Click(Sender: TObject);    procedure FormClose(Sender: TObject; var Action: TCloseAction);    procedure MlSkinColorButton2Click(Sender: TObject);    procedure FormCreate(Sender: TObject);    procedure MlSkinColorButton3Click(Sender: TObject);  private    { Private declarations }  public    { Public declarations }    function Decrypt(const s: string; key: word): string;  end;var  Form7: TForm7;implementationuses mainunit;{$R *.dfm}function MacAddress: string;               var Lib: Cardinal; Func : function(GUID: PGUID): Longint; stdcall;  GUID1, GUID2: TGUID;begin Result := ''; Lib := LoadLibrary('rpcrt4.dll');  if Lib <> 0 then begin   if Win32Platform <>VER_PLATFORM_WIN32_NT then     @Func := GetProcAddress(Lib, 'UuidCreate')     else @Func := GetProcAddress(Lib, 'UuidCreateSequential');   if Assigned(Func) then   begin     if (Func(@GUID1) = 0) and       (Func(@GUID2) = 0) and       (GUID1.D4[2] = GUID2.D4[2]) and       (GUID1.D4[3] = GUID2.D4[3]) and       (GUID1.D4[4] = GUID2.D4[4]) and       (GUID1.D4[5] = GUID2.D4[5]) and       (GUID1.D4[6] = GUID2.D4[6]) and       (GUID1.D4[7] = GUID2.D4[7]) then     begin       Result :=        IntToHex(GUID1.D4[2], 2) + '1A' +        IntToHex(GUID1.D4[3], 2) + 'B2' +        IntToHex(GUID1.D4[4], 2) + '2E' +        IntToHex(GUID1.D4[5], 2) + '4C' +        IntToHex(GUID1.D4[6], 2) + 'D3' +        IntToHex(GUID1.D4[7], 2);     end;   end;   FreeLibrary(Lib); end;end;function TForm7.Decrypt(const s: string; key: word): string;var  i:byte;  R:String;const  C1=50;  C2=50;begin  SetLength(R,Length(s));  for i:=1 to Length(s) do  begin    R[i]:=char(byte(s[i]) xor (key shr 8));    key:=(byte(s[i])+key)+C1+C2  end;  Result:=R;end;procedure TForm7.MlSkinColorButton1Click(Sender: TObject);var ARegistry:TRegistry;  begin  //  Editid.Text:=GetCPUSerialNumber;    if code.text=Decrypt(MacAddress,100) then  //如输入的注册码正确,则把注册码保存到注册表    begin    MlSkinLabel3.Caption:='注册码正确,请重启软件';      ARegistry := TRegistry.Create;      with ARegistry do      begin        RootKey:=HKEY_LOCAL_MACHINE;        if OpenKey('Software\hahalogin',True) then          WriteString('code',code.text);  //form7.close;   self.hide;  mainfrm := tmainfrm.create(self);  mainfrm.ShowModal;  mainfrm.Free;   Free;      end;    end    else    if code.text<>Decrypt(MacAddress,100) then    MlSkinLabel3.Caption:='注册码错误,请重新输入。';  end;procedure TForm7.FormClose(Sender: TObject; var Action: TCloseAction);begin//action:=caFreeend;procedure TForm7.MlSkinColorButton2Click(Sender: TObject);beginApplication.Terminate;end;procedure TForm7.FormCreate(Sender: TObject);var ARegistry:TRegistry; RegisterCode:string;beginedit1.Text:=MacAddress;  ARegistry := TRegistry.Create;  with ARegistry do  begin    RootKey:=HKEY_LOCAL_MACHINE;    if OpenKey('Software\hahalogin',false ) then      RegisterCode:=ReadString('code');    ARegistry.Free;  end;  //根据机器标识算出注册码,和已保存的注册码比较,看是否已注册   if   RegisterCode= Decrypt(MacAddress,100) then  begin  self.hide;  mainfrm := tmainfrm.create(self);  mainfrm.ShowModal;  mainfrm.Free;  // mainfrm.Show;  // form7.close;  { end   else   if   RegisterCode <> edit1.Text then   begin   label3.Caption:='请注册';  }   end; end;procedure TForm7.MlSkinColorButton3Click(Sender: TObject);beginClipBoard.AsText := edit1.Text;end;end.
0 0