主程式檔案:main.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "main.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TMainForm
*MainForm;
//---------------------------------------------------------------------------
__fastcall TMainForm::TMainForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::Exit_BtnClick(TObject *Sender)
{
Application->Terminate();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::ID_EditKeyPress(TObject *Sender, char &Key)
{
if(Key<'0' | Key>'9')
{
if(Key=='\b')
{return;}
Application->MessageBoxA("請輸入一個數字,否則你將得不到正確的結果!","錯誤",MB_OK);
Key=NULL;
return;
}
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::ID_EditChange(TObject *Sender)
{
AnsiString
REG_Temp;
ULONG NUM_Temp;
DWORD ASC_Temp;
NUM_Temp=0;
if(User_Edit->Text.Length()<6)
{
Key_Edit->Text="使用者名稱的長度不能少於6位";
return;
}
if(ID_Edit->Text=="")
{
Key_Edit->Text="待註冊碼不能為空";
return;
}
REG_Temp=ID_Edit->Text+User_Edit->Text;
for(int i=1;i<=REG_Temp.Length();i++)
{
ASC_Temp=REG_Temp[i]*(i+3);
NUM_Temp=NUM_Temp+ASC_Temp;
}
NUM_Temp=NUM_Temp*0x43C9;
NUM_Temp=NUM_Temp+0x595EFBB;
Key_Edit->Text=AnsiString(NUM_Temp); ;這裡就是註冊碼了
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::Web_LabelClick(TObject *Sender)
{
ShellExecute(Handle,"open","http://WWW.DOWNCRACK.COM/",NULL,NULL,SW_MAXIMIZE);
}
//---------------------------------------------------------------------------
標頭檔案:main.h
//---------------------------------------------------------------------------
#ifndef mainH
#define mainH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Buttons.hpp>
//---------------------------------------------------------------------------
class TMainForm : public TForm
{
__published: //
IDE-managed Components
TLabel *ID_Label;
TLabel *Reg_Label;
TEdit *ID_Edit;
TEdit *Key_Edit;
TBitBtn *Exit_Btn;
TLabel
*Web_Label;
TLabel *Label2;
TLabel *Label3;
TLabel *Label1;
TLabel *User_Label;
TEdit *User_Edit;
void __fastcall Exit_BtnClick(TObject
*Sender);
void __fastcall ID_EditKeyPress(TObject
*Sender, char &Key);
void __fastcall ID_EditChange(TObject
*Sender);
void __fastcall Web_LabelClick(TObject
*Sender);
private: // User declarations
public:
// User declarations
__fastcall TMainForm(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TMainForm *MainForm;
//---------------------------------------------------------------------------
#endif