//--------------------------------------------------------------------------- #include #pragma hdrstop #include #include "Des.h" #include "timeLock_F.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TtimeLockForm *timeLockForm; //--------------------------------------------------------------------------- __fastcall TtimeLockForm::TtimeLockForm(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TtimeLockForm::FormCreate(TObject *Sender) { GetLocalTime(&st); Label3->Caption = Format("%d : %d : %d", OPENARRAY(TVarRec, (st.wYear, st.wMonth, st.wDay))); } //--------------------------------------------------------------------------- int __fastcall TtimeLockForm::toJulian() { int jyear, jmonth, jul, greg, curDay, ja; jyear = st.wYear; jmonth = st.wMonth; if (st.wYear < 0) jyear++; if (st.wMonth > 2) jmonth++; else { jyear--; jmonth += 13; } jul = 365.25*jyear + 30.6001*jmonth + st.wDay + 1720995.0; greg = 15 + 31*(10+12*1582); curDay = st.wDay + 31*(st.wMonth +12*st.wYear); if (curDay >= greg) { ja = 0.01*jyear; jul += 2-ja+(0.25*ja); } return jul; } //--------------------------------------------------------------------------- void __fastcall TtimeLockForm::btLockClick(TObject *Sender) { int sumDay; unsigned char blk[8], k[8] = {'^', '*', 'F', 'S', '0', '>', '?', '['}; AnsiString str; sumDay = toJulian(); blk[0] = sumDay & 0xFF; blk[1] = (sumDay >> 8) & 0xFF; blk[2] = (sumDay >> 16) & 0xFF; blk[3] = (sumDay >> 24) & 0xFF; sumDay = StrToInt(edDue->Text); blk[4] = sumDay & 0xFF; blk[5] = (sumDay >> 8) & 0xFF; blk[6] = (sumDay >> 16) & 0xFF; blk[7] = (sumDay >> 24) & 0xFF; encrypt(k, blk); Label1->Caption = Format("%d-%d-%d-%d", OPENARRAY(TVarRec, ((blk[1]<<8)|blk[0], (blk[3]<<8)|blk[2], (blk[5]<<8)|blk[4], (blk[7]<<8)|blk[6]))); SaveToRegistry(); } //--------------------------------------------------------------------------- void __fastcall TtimeLockForm::btUnlockClick(TObject *Sender) { Application->Terminate(); } //--------------------------------------------------------------------------- void __fastcall TtimeLockForm::SaveToRegistry() { TRegIniFile *RegIniFile; RegIniFile = new TRegIniFile(REGFILENAME); RegIniFile->RootKey = HKEY_LOCAL_MACHINE; RegIniFile->OpenKey("SOFTWARE\\YoungWoo\\Texpro\\8.01\\",true); if (RegIniFile) { RegIniFile->WriteString("Common", "Product No.", Label1->Caption); delete RegIniFile; } }