📄 client_c.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include <stdlib.h>
#pragma hdrstop
#include "winbase.h"
#include "fcntl.h"
#include "stdio.h"
#include "math.h"
#include "About.h"
#include "client_c.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if((Edit2->Text=="")||(Edit4->Text==""))
return;
ClientSocket1->Address=Edit4->Text;
ClientSocket1->Port=atoi(Edit2->Text.c_str());
ClientSocket1->Open();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ClientSocket1Connect(TObject *Sender,
TCustomWinSocket *Socket)
{
if((Edit1->Text=="edit conf 1")||(Edit1->Text=="edit conf 2"))
Socket->SendText(Edit1->Text+Edit5->Text);
else
Socket->SendText(Edit1->Text);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ClientSocket1Read(TObject *Sender,
TCustomWinSocket *Socket)
{
AnsiString ReadIn = Socket->ReceiveText();
Edit3->Text="";
FILE *fp;
fp = fopen("ReadIn.tmp","w");
fwrite( ReadIn.c_str(),1,10000,fp);
fclose(fp);
Edit3->Lines->LoadFromFile("ReadIn.tmp");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit1KeyPress(TObject *Sender, char &Key)
{
if(Key==VK_RETURN)
Button1Click(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit2KeyPress(TObject *Sender, char &Key)
{
if(Key==VK_RETURN)
Button1Click(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Panel1Click(TObject *Sender)
{
OKBottomDlg->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
GetSystemInfo(&info);
FILE *fp;
fp=fopen("SerialKey.dat","wb");
fwrite(&info,sizeof(info),1,fp);
fclose(fp);
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);
Registry=new TRegistry;
Registry->RootKey=HKEY_LOCAL_MACHINE;
AnsiString UserRegistName, SerialNum;
Registry->OpenKey("Software\\Client/Server",true);
try
{
UserRegistName=Registry->ReadString("User Name");
}
catch(...)
{
}
if(UserRegistName==NULL)
{
RegistOrNot=false;
Application->MessageBoxA("This software haven't register now, you should register it now!","Warnning", MB_OK);
}
else
{
try
{
SerialNum=Registry->ReadString("Serial Num");
}
catch(...)
{
}
if(SerialNum==NULL)
{
RegistOrNot=false;
Application->MessageBoxA("This software haven't register now, you should register it now!","Warnning", MB_OK);
}
else
{
if( SerialNum.AnsiCompare( AnsiString( abs((T1+T2+T3+T4+T5+T6)^(int)( pow(69 , UserRegistName.Length()))) )))
{
RegistOrNot=false;
Application->MessageBoxA("This software haven't register now, you should register it now!","Warnning", MB_OK);
}
else
RegistOrNot=true;
}
}
Registry->CloseKey();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
Application->HelpCommand(1, 0);
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -