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

📄 pubunit.pas

📁 超级播放器 -- 软件特点 -- 功能齐全 操作简便 绿色环保
💻 PAS
字号:
unit pubUnit;

interface
uses Inifiles,sysutils,Forms,Windows,dialogs,Registry;//,FileCtrl;
const
     SIG_MYFILE='wangxw';
     INI_NAME = 'SysSet.ini';

     PWDKEY=987;//密钥
type
        TCPUID  = array[1..4] of Longint;
  TVideoParam=Record
    VideoStandard:longint; //视频端口制式
    VideoSource:Longint;   //视频端口号
    Brightness:Longint;    //亮度
    Contrast:longint;      //对比度
    Hue:Longint;           //色度
    Saturation:Longint;    //饱和度
    PreviewType:Longint;   //视频显示格式
    PreviewWidth:Longint;  //视频显示宽度
    PreviewHeight:Longint; //视频显示高度
  end;
  TOtherSetParam=Record
    SaveDir:string;        //保存路径
    SaveType:byte;         //保存类型
    ImgQuality:integer;    //保存图象质量(对于Jpg格式)
    MinSpace:integer;      //最小磁盘容量
    SnapshotDir:string;    //快照保存路径
  end;
  TCommSetParam=Record     //串口通信设置
    CommSettings:string;
    CommPort:byte;
  end;
  TLogoSetParam=Record //Logo设置
    LogoFile:string;       //
    xLogo,yLogo:integer;
    showLogo:boolean;
    xDate,yDate:integer;
    showDate:boolean;
    xTime,yTime:integer;
    showTime:boolean;
  end;
  //将字符串射为指定长度,不够用空格(' ')或'0'替代
  Function FormatStr(S:string;pLen:integer;posLeft,useSpace:boolean):string;
  Function GetOtherSet:TOtherSetparam;
  Function GetLogoSet:TLogoSetparam;
  procedure SetLogo(vLogoSet:TLogoSetparam);
  Function GetCommSet:TCommSetParam;
  procedure SetComm(vCommSet:TCommSetParam);
  function GetPwd(vType:string):string;
  procedure setPwd(vPwd,vType:string);

  function RegisterOleFile (strOleFileName : STRING; OleAction : Byte ) : BOOLEAN;
  function isDiskSpaceLess:boolean;
  function GetSysDir: String;
  function GetWinDir: String;
  function GetCPUID : TCPUID; assembler; register;
  function GetHDSerialNumber: string;

  function Registok(zc_code,sq_code:string):boolean;

implementation
  uses u_Crypt;

function GetCPUID : TCPUID; assembler; register;
asm
  PUSH    EBX         {Save affected register} 
  PUSH    EDI 
  MOV     EDI,EAX     {@Resukt} 
  MOV     EAX,1 
  DW      $A20F       {CPUID Command} 
  STOSD                           {CPUID[1]} 
  MOV     EAX,EBX
  STOSD               {CPUID[2]} 
  MOV     EAX,ECX 
  STOSD               {CPUID[3]}
  MOV     EAX,EDX 
  STOSD               {CPUID[4]} 
  POP     EDI                                   {Restore registers} 
  POP     EBX 
end;
function GetHDSerialNumber: string;
{$IFDEF WIN32} 
var
  pdw : pDWord; 
  mc, fl : dword; 
{$ENDIF} 
begin 
  {$IfDef WIN32} 
  New(pdw);
  GetVolumeInformation(nil,nil,0,pdw,mc,fl,nil,0); 
  Result :=// pdw^;
          IntToHex(HiWord(pdw^), 4) +
               '-' +
               IntToHex(LoWord(pdw^), 4);
  dispose(pdw);
  {$ELSE} 
  Result := inttostr(GetWinFlags);
  {$ENDIF} 
end;

Function GetOtherSet:TOtherSetparam;
var
  vIniFile:TIniFile;
  OtherSet:TOtherSetParam;
begin
  vIniFile:=TIniFile.Create(extractfiledir(application.ExeName )+'\'+INI_NAME);
  try
    OtherSet.SaveDir :=Decrypt(vIniFile.ReadString('Other','SaveDir',extractfiledir(application.ExeName)+'\'),PWDKEY);
    OtherSet.SaveType:=vIniFile.ReadInteger('Other','SaveType',1);
    OtherSet.ImgQuality:=vIniFile.ReadInteger('Other','ImgQuality',65);
    OtherSet.MinSpace:=vIniFile.ReadInteger('Other','MinSpace',100);
    OtherSet.SnapshotDir:=Decrypt(vIniFile.ReadString('Other','SnapshotDir',extractfiledir(application.ExeName)+'\'),PWDKEY);
    Result:=OtherSet;
  finally
    Result:=OtherSet;
    vInifile.free;
  end;
end ;
Function GetLogoSet:TLogoSetparam;
var
  vIniFile:TIniFile;
  LogoSet:TLogoSetparam;
begin
  vIniFile:=TIniFile.Create(extractfiledir(application.ExeName )+'\'+INI_NAME);
  try
    LogoSet.LogoFile :=vIniFile.ReadString('Logo','LogoFile','');
    LogoSet.xLogo:=vIniFile.ReadInteger('Logo','xLogo',5);
    LogoSet.yLogo:=vIniFile.ReadInteger('Logo','yLogo',5);
    LogoSet.showLogo :=vIniFile.ReadBool('Logo','ShowLogo',false);
    LogoSet.xDate:=vIniFile.ReadInteger('Logo','xDate',110);
    LogoSet.yDate:=vIniFile.ReadInteger('Logo','yDate',5);
    LogoSet.showDate :=vIniFile.ReadBool('Logo','ShowDate',false);
    LogoSet.xTime:=vIniFile.ReadInteger('Logo','xTime',220);
    LogoSet.yTime:=vIniFile.ReadInteger('Logo','yTime',5);
    LogoSet.showTime :=vIniFile.ReadBool('Logo','ShowTime',false);

    Result:=LogoSet;
  finally
    Result:=LogoSet;
    vInifile.free;
  end;
end ;
procedure SetLogo(vLogoSet:TLogoSetparam);
var
  vIniFile:TIniFile;
begin
  vIniFile:=TIniFile.Create(extractfiledir(application.ExeName )+'\'+INI_NAME);
  try
     vIniFile.WriteString('Logo','LogoFile',vLogoSet.LogoFile);
     vIniFile.WriteInteger('Logo','xLogo',vLogoSet.xLogo);
     vIniFile.WriteInteger('Logo','yLogo',vLogoSet.yLogo);
     vIniFile.WriteBool('Logo','ShowLogo',vLogoSet.ShowLogo);
     vIniFile.WriteInteger('Logo','xDate',vLogoSet.xDate);
     vIniFile.WriteInteger('Logo','yDate',vLogoSet.yDate);
     vIniFile.WriteBool('Logo','ShowDate',vLogoSet.ShowDate);
     vIniFile.WriteInteger('Logo','xTime',vLogoSet.xTime);
     vIniFile.WriteInteger('Logo','yTime',vLogoSet.yTime);
     vIniFile.WriteBool('Logo','ShowTime',vLogoSet.ShowTime);
  finally
    vInifile.free;
  end;
end;
Function GetCommSet:TCommSetParam;
var
  vIniFile:TIniFile;
  CommSet:TCommSetParam;
begin
  vIniFile:=TIniFile.Create(extractfiledir(application.ExeName )+'\'+INI_NAME);
  try
    CommSet.CommSettings :=vIniFile.ReadString('CommSet','CommSettings','9600,n,8,1');
    CommSet.CommPort:=vIniFile.ReadInteger('CommSet','CommPort',1);
    Result:=CommSet;
  finally
    Result:=CommSet;
    vInifile.free;
  end;
end;
procedure SetComm(vCommSet:TCommSetParam);
var
  vIniFile:TIniFile;
begin
  vIniFile:=TIniFile.Create(extractfiledir(application.ExeName )+'\'+INI_NAME);
  try
    vIniFile.writestring('CommSet','CommSettings',vCommSet.CommSettings );
    vIniFile.writeinteger('CommSet','CommPort',vCommSet.CommPort);
  finally
    vInifile.free;
  end;
end;
Function FormatStr(S:string;pLen:integer;posLeft,useSpace:boolean):string;   //将字符串射为指定长度,不够用空格(' ')或'0'替代
var
  i:integer;
  insertChar:char;
begin
  if useSpace then
    insertChar:=' '
  else
    insertChar:='0';
  for i:=1 to pLen-Length(s) do
    if posLeft then
      Insert(insertChar,S,0)
    else
      Insert(InsertChar,S,Length(s)+1);
  FormatStr:=S;
end;
function GetPwd(vType:string):string;
var
  vIniFile:TIniFile;
begin
  vIniFile:=TIniFile.Create(extractfiledir(application.ExeName )+'\'+INI_NAME);
  try
    Result:=vIniFile.ReadString('Pwd',vType,'BYHEER'); //初始密码123
  finally
    vInifile.free;
  end;
end;
procedure setPwd(vPwd,vType:string);
var
  vIniFile:TIniFile;
begin
  vIniFile:=TIniFile.Create(extractfiledir(application.ExeName )+'\'+INI_NAME);
  try
     vInifile.WriteString('Pwd',vType,vPwd);
  finally
     vINiFile.free;
  end;
end;
function RegisterOleFile (strOleFileName : STRING; OleAction : Byte ) : BOOLEAN;
const
   RegisterOle = 1;//注册
   UnRegisterOle = 0;//卸载
type
   TOleRegisterFunction = function : HResult;//注册或卸载函数的原型
var
   hLibraryHandle : THandle;//由LoadLibrary返回的DLL或OCX句柄
   hFunctionAddress: TFarProc;//DLL或OCX中的函数句柄,由GetProcAddress返回
   RegFunction : TOleRegisterFunction;//注册或卸载函数指针
   registerTemp : TRegistry;
begin
  Result := FALSE;

  registerTemp := TRegistry.Create; //准备使用注册表
  with registerTemp do
  begin
    RootKey:=HKEY_CLASSES_ROOT; //存放在此根下
    if OpenKey('Licenses\4250E830-6AC2-11cf-8ADB-00AA00C00905',True) then
    begin
        WriteString('','kjljvjjjoquqmjjjvpqqkqmqykypoqjquoun');
        //打开OLE/DCOM文件,返回的DLL或OCX句柄
        hLibraryHandle := LoadLibrary(PCHAR(strOleFileName));
        if (hLibraryHandle > 0) then//DLL或OCX句柄正确
          try
            //返回注册或卸载函数的指针
            if (OleAction = RegisterOle) then//返回注册函数的指针
              hFunctionAddress := GetProcAddress(hLibraryHandle, pchar('DllRegisterServer'))
            else                             //返回卸载函数的指针
              hFunctionAddress := GetProcAddress(hLibraryHandle, pchar('DllUnregisterServer'));
            if (hFunctionAddress <> NIL) then//注册或卸载函数存在
            begin
              RegFunction := TOleRegisterFunction(hFunctionAddress);//获取操作函数的指针
              if RegFunction >= 0 then //执行注册或卸载操作,返回值>=0表示执行成功
                result := true;
            end;
          finally
            FreeLibrary(hLibraryHandle);//关闭已打开的OLE/DCOM文件
          end;

      CloseKey;
      Free;
    end;
  end;
end;
function isDiskSpaceLess:boolean;
var
    secspclu,bytespsec,freeclu,totalclu,ts,fs:DWord;
    s:string;
begin
    s:=extractfiledrive(getotherset.SaveDir ) ;
    Result:= (((diskfree(ord(s[1])-$40) div 1024) div 1024) < GetOtherSet.MinSpace);
     exit;

    GetDiskFreeSpace(PChar(extractfiledrive(GetOtherSet.SaveDir)),secspclu,bytespsec,freeclu,totalclu);
    fs:=freeclu*secspclu*bytespsec;
    //磁盘的剩余空间(字节为单位)

 //   ts:=totalclu*secspclu*bytespsec;
    //磁盘的总容量(字节为单位)
     result:=((fs div 1024) div 1024 <GetOtherSet.MinSpace );

 //   edit2.text:=formatfloat('###,###',fs);
 //   edit1.text:=formatfloat('###,###',ts);
    //将结果格式化并显示在两个TEdit组件中
end;
function GetSysDir: String;
var
  Temp: array[0..255] of Char;
begin
  GetSystemDirectory(Temp, 256);
  Result := StrPas(Temp);
end;
function GetWinDir: String;
var
  Temp: array[0..255] of Char;
begin
  GetWindowsDirectory(Temp, 256);
  Result := StrPas(Temp);
end;
function Registok(zc_code,sq_code:string):boolean;
var oldcode1,oldcode2,s1,s2,s3,s4,tempstr:string;
  P:integer;
begin
//******由注册申请码,得到机器码----Start********
  tempstr:=sq_code;

  p:=pos('-',tempstr);
  s1:=copy(tempstr,1,p-1);
  tempstr:=copy(tempstr,p+1,length(tempstr)-p);

  p:=pos('-',tempstr);
  s4:=copy(tempstr,1,p-1);
  tempstr:=copy(tempstr,p+1,length(tempstr)-p);

  p:=pos('-',tempstr);
  s3:=copy(tempstr,1,p-1);
  tempstr:=copy(tempstr,p+1,length(tempstr)-p);

  s2:=tempstr;

  s1:=decrypt2(s1,393);
  s2:=decrypt2(s2,393);
  s3:=decrypt2(s3,393);
  s4:=decrypt2(s4,393);
  oldcode1:=s1+'-'+s2+'-'+s3+'-'+s4;
//******由注册申请码,得到机器码----End********


//******由注册码,得到机器码--------Start********
  tempstr:=zc_code;

  p:=pos('-',tempstr);
  s2:=copy(tempstr,1,p-1);
  tempstr:=copy(tempstr,p+1,length(tempstr)-p);

  p:=pos('-',tempstr);
  s4:=copy(tempstr,1,p-1);
  tempstr:=copy(tempstr,p+1,length(tempstr)-p);

  p:=pos('-',tempstr);
  s3:=copy(tempstr,1,p-1);
  tempstr:=copy(tempstr,p+1,length(tempstr)-p);

  s1:=tempstr;

  s1:=decrypt2(s1,398);
  s2:=decrypt2(s2,398);
  s3:=decrypt2(s3,398);
  s4:=decrypt2(s4,398);

  oldcode2:=s1+'-'+s2+'-'+s3+'-'+s4;
//******由注册码,得到机器码--------End********

  //比较两者得到的机器码是否相同
  result:=(oldcode1=oldcode2);
end;


end.

⌨️ 快捷键说明

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