www.pudn.com > 远程控制程序.rar > Regist.cpp


//--------------------------------------------------------------------- 
#include  
#pragma hdrstop 
 
#include "winbase.h" 
#include "stdio.h" 
#include "math.h" 
#include "Regist.h" 
//--------------------------------------------------------------------- 
#pragma resource "*.dfm" 
TOKBottomDlg1 *OKBottomDlg1; 
//--------------------------------------------------------------------- 
__fastcall TOKBottomDlg1::TOKBottomDlg1(TComponent* AOwner) 
	: TForm(AOwner) 
{ 
} 
//--------------------------------------------------------------------- 
void __fastcall TOKBottomDlg1::OKBtnClick(TObject *Sender) 
{ 
        GetSystemInfo(&info); 
        int T1 = info.dwProcessorType; 
        int T2 = info.wProcessorLevel; 
        int T3 = info.dwNumberOfProcessors; 
        int T4 = info.wProcessorRevision; 
        int T5 = T1+T2+T3+T4; 
        int T6 = T1^T2+T4^T3; 
 
        for(int i=0;i<37;i++) 
        { 
        T1 = (T1 + T2 + 0x1234)^0x2345; 
        T2 = (T2 + T3 + 0x2345)^0x3456; 
        T3 = (T3 + T4 + 0x3456)^0x4567; 
        T4 = (T4 + T5 + 0x4567)^0x5678; 
        T5 = (T5 + T6 + 0x5678)^0x6789; 
        T6 = (T6 + T1 + 0x6789)^0x7890; 
        } 
 
        int UserNameLength = Edit1->Text.Length(); 
//      Serial Key is: AnsiString((T1+T2+T3+T4+T5+T6)^UserNameLength); 
 
        char information[500]; 
        sprintf(information,"%s%s%s%s","Your register name and code are:\n",Edit1->Text.c_str(),"\n",Edit2->Text.c_str()); 
 
        if(!Edit2->Text.AnsiCompare(AnsiString( abs((T1+T2+T3+T4+T5+T6)^(int)( pow(69 , UserNameLength)))  ))) 
        { 
                Registry=new TRegistry(); 
                Registry->RootKey=HKEY_LOCAL_MACHINE;                 
                Registry->OpenKey("Software\\Client/Server",true); 
                Registry->WriteString("User Name",Edit1->Text); 
                Registry->WriteString("Serial Num",Edit2->Text); 
                Registry->CloseKey();                 
                Application->MessageBoxA(information , "Congratulation",MB_OK); 
        } 
        else 
                Application->MessageBoxA("Your name and code are not right!", "Error",MB_OK); 
} 
//---------------------------------------------------------------------------