⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main_unit.cpp

📁 GIS+VB开发. GIS+VB开发.
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Main_Unit.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TMainFrm *MainFrm;
HINSTANCE ins;
FARPROC procCPU,procDisk;
typedef char * (__stdcall *TGetStrFun)(LPCSTR);
typedef void (__stdcall *TDes)(char*,char*,char*,int);

TGetStrFun procMD5,procSN,proc;
TDes procDes;
//---------------------------------------------------------------------------
__fastcall TMainFrm::TMainFrm(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TMainFrm::pnlTitleMouseDown(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
    // 移动没有标题栏的窗体
    Refresh();
    if(Button == mbLeft)
    {
        ReleaseCapture();
        Perform(WM_SYSCOMMAND, 0xF017, 0);
    }
}
//---------------------------------------------------------------------------

void __fastcall TMainFrm::btnMenuUpDownClick(TObject *Sender)
{
    if(btnMenuUpDown->Caption == "6")
    {
        // 还原窗体
        btnMenuUpDown->Caption = "5";
        Height = 350;
    }
    else
    {
        // 上卷窗体
        btnMenuUpDown->Caption = "6";
        Height = 25;
    }
}
//---------------------------------------------------------------------------

void __fastcall TMainFrm::imgLogoMouseDown(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
  ShellExecute(Handle, NULL, "http://zydlm.wxhc.com.cn", NULL, NULL, SW_SHOWNORMAL);        
}
//---------------------------------------------------------------------------

void __fastcall TMainFrm::btnMenuCloseClick(TObject *Sender)
{
  Close();        
}
//---------------------------------------------------------------------------

void __fastcall TMainFrm::FormCreate(TObject *Sender)
{
  ins=LoadLibrary("Reg.dll");
  if (ins!=NULL)
  {
    btnGet->Enabled =true;
    btnBorwse->Enabled=true;
    btnBorwse1->Enabled=true;
  }
}
//---------------------------------------------------------------------------

void __fastcall TMainFrm::btnGetClick(TObject *Sender)
{
  if (ins!=NULL)
  {
    //取硬盘序列号的函数
    procDisk=GetProcAddress(ins,"ReadPhysicalDrive");

    //取CPU序列号的函数
    procCPU=GetProcAddress(ins,"GetCPUID");

    //得到DES函数的函数
    procDes=(TDes)GetProcAddress(ins,"Des");

    //得到MD5函数的函数
    procMD5=(TGetStrFun)GetProcAddress(ins,"GetMD5Str");

    //产生序列号
    procSN=(TGetStrFun)GetProcAddress(ins,"CreateSerialNumber");

    if ((procDisk)&&(procDes)&&(procCPU)&&(procMD5))
    {
      char *p;
      char buf[128];

      //取硬盘序列号
      p=(char*)procDisk();
      edtDiskID->Text=p;

      edtDiskDes->Text=procMD5(edtDiskID->Text.c_str());
//      procDes(p,buf,"2004",0);
//      edtDiskDes->Text=buf;

      //取CPU序列号
      p=(char*)procCPU();
      edtCPU->Text=p;

//      edtCPUDes->Text=procMD5(edtCPU->Text.c_str());
      procDes(p,buf,"2004",0);
      edtCPUDes->Text=buf;

//      edtCode->Text=edtDiskID->Text+"-"+edtCPU->Text;
      btnCount->Enabled =true;
      btnCount->Visible =true;
    }
  }
}
//---------------------------------------------------------------------------

void __fastcall TMainFrm::FormDestroy(TObject *Sender)
{
  FreeLibrary(ins);        
}
//---------------------------------------------------------------------------

void __fastcall TMainFrm::btnCountClick(TObject *Sender)
{
  if (ins!=NULL)
  {
    procMD5=(TGetStrFun)GetProcAddress(ins,"CreateSerialNumber");
    if (procMD5!=NULL)
    {
      char *p;
      p=(char*)procMD5(edtCode->Text.c_str());
      edtSN->Text=p;
    }
  }
}
//---------------------------------------------------------------------------


void __fastcall TMainFrm::pclMainDrawTab(TCustomTabControl *Control,
      int TabIndex, const TRect &Rect, bool Active)
{
  WideString Scaption=pclMain->Pages[TabIndex]->Caption;
  AnsiString smallcaption=Scaption.SubString(1,4);
  if(Active)
   {
     Control->Canvas->Brush->Color =(TColor)0x00EFDBCE; //(TColor)RGB(230,230,255);
     Control->Canvas->FillRect(TRect(Rect.Left , Rect.Top, Rect.Right, Rect.Bottom));
     Control->Canvas->Pen->Color = (TColor)RGB(0,0,200);
     Control->Canvas->Brush->Style = bsClear;

     Control->Canvas->Rectangle(TRect(Rect.Left , Rect.Top, Rect.Right, Rect.Bottom));
     Control->Canvas->Font->Color=clRed;
     Control->Canvas->TextOutA(Rect.Left+4 , Rect.Top + 2,  smallcaption);
   }
   else
   {
     Control->Canvas->Brush->Color = (TColor)0x00EFDBCE;
     Control->Canvas->FillRect(TRect(Rect.Left -3, Rect.Top-3, Rect.Right, Rect.Bottom));
     Control->Canvas->Pen->Color = (TColor)0x00EFDBCE;//clBlack;

     Control->Canvas->Brush->Style = bsClear;
     Control->Canvas->Rectangle(TRect(Rect.Left , Rect.Top, Rect.Right, Rect.Bottom));
     Control->Canvas->Font->Color=clGreen;
     Control->Canvas->TextOutA(Rect.Left+4 , Rect.Top+2 ,  smallcaption);
   }
}
//---------------------------------------------------------------------------


void __fastcall TMainFrm::btnBorwseClick(TObject *Sender)
{
  TOpenDialog *mdlg;
  mdlg=new TOpenDialog(this);
  mdlg->InitialDir =ExtractFilePath(ParamStr(0));
  mdlg->Filter ="全部文件(*.*)|*.*";
  if (mdlg->Execute())
  {
    edtcoFile->Text=mdlg->FileName;
    btnCompress->Enabled =true;
  }
  delete mdlg;
}
//---------------------------------------------------------------------------

void __fastcall TMainFrm::btnBorwse1Click(TObject *Sender)
{
  TOpenDialog *mdlg;
  mdlg=new TOpenDialog(this);
  mdlg->InitialDir =ExtractFilePath(ParamStr(0));
  mdlg->Filter ="压缩文件(*.lg)|*.lg";
  if (mdlg->Execute())
  {
    edtdeFile->Text=mdlg->FileName;
    btnDeCompress->Enabled =true;
  }
  delete mdlg;
}
//---------------------------------------------------------------------------

void __fastcall TMainFrm::btnCompressClick(TObject *Sender)
{
  if (ins!=NULL)
  {
    proc=(TGetStrFun)GetProcAddress(ins,"CompressData");
    if (proc!=NULL)
    {
      bool bSuccess=false;
      bSuccess=proc(edtcoFile->Text.c_str());
      if (bSuccess)
        ShowMessage("压缩成功!");
      else
        ShowMessage("压缩失败!");
    }
  }
}
//---------------------------------------------------------------------------

void __fastcall TMainFrm::btnDeCompressClick(TObject *Sender)
{
  if (ins!=NULL)
  {
    proc=(TGetStrFun)GetProcAddress(ins,"DeCompressData");
    if (proc!=NULL)
    {
      bool bSuccess=false;
      bSuccess=proc(edtdeFile->Text.c_str());
      if (bSuccess)
        ShowMessage("解压成功!");
      else
        ShowMessage("解压失败!");
    }
  }
}
//---------------------------------------------------------------------------

void __fastcall TMainFrm::edtCodeChange(TObject *Sender)
{
  if (ins!=NULL)
  {
    if (edtCode->Text!="")
      btnCount->Enabled =true;
    else
      btnCount->Enabled =false;
  }

}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -