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

📄 unit1.pas

📁 理论考试程序,可以自由下载,学习,请多多指点,批评
💻 PAS
📖 第 1 页 / 共 2 页
字号:
  hDevice : THandle;
  cbBytesReturned : DWORD;
  pInData : PSendCmdInParams;
  pOutData : Pointer; // PSendCmdOutParams
  Buffer : Array[0..BufferSize-1] of Byte;
  srbControl : TSrbIoControl absolute Buffer;

procedure ChangeByteOrder( var Data; Size : Integer );
var
  ptr : PChar;
  i : Integer;
  c : Char;
begin
  ptr := @Data;
  for i := 0 to (Size shr 1)-1 do
  begin
    c := ptr^;
    ptr^ := (ptr+1)^;
    (ptr+1)^ := c;

    Inc(ptr,2);
  end;
end;

begin
  Result :='';
  FillChar(Buffer,BufferSize,#0);
  if Win32Platform=VER_PLATFORM_WIN32_NT then // Windows NT, Windows 2000
  begin         // Get SCSI port handle
    hDevice := CreateFile( '\\.\Scsi0:',GENERIC_READ or GENERIC_WRITE,
    FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, 0, 0 );
    if hDevice=INVALID_HANDLE_VALUE then Exit;
    try
      srbControl.HeaderLength := SizeOf(SRB_IO_CONTROL);
      System.Move('SCSIDISK',srbControl.Signature,8);
      srbControl.Timeout := 2;
      srbControl.Length := DataSize;
      srbControl.ControlCode := IOCTL_SCSI_MINIPORT_IDENTIFY;
      pInData := PSendCmdInParams(PChar(@Buffer)
      +SizeOf(SRB_IO_CONTROL));
      pOutData := pInData;
      with pInData^ do
      begin
        cBufferSize := IDENTIFY_BUFFER_SIZE;
        bDriveNumber := 0;
        with irDriveRegs do
        begin
          bFeaturesReg := 0;
          bSectorCountReg := 1;
          bSectorNumberReg := 1;
          bCylLowReg := 0;
          bCylHighReg := 0;
          bDriveHeadReg := $A0;
          bCommandReg := IDE_ID_FUNCTION;
        end;
      end;
      if not DeviceIoControl( hDevice, IOCTL_SCSI_MINIPORT,
      @Buffer, BufferSize, @Buffer, BufferSize,
      cbBytesReturned, nil ) then Exit;
    finally
      CloseHandle(hDevice);
    end;
  end else
  begin // Windows 95 OSR2, Windows 98
    hDevice := CreateFile( '\\.\SMARTVSD', 0, 0, nil,CREATE_NEW, 0, 0 );
    if hDevice=INVALID_HANDLE_VALUE then Exit;
    try
      pInData := PSendCmdInParams(@Buffer);
      pOutData := @pInData^.bBuffer;
      with pInData^ do
      begin
        cBufferSize := IDENTIFY_BUFFER_SIZE;
        bDriveNumber := 0;
        with irDriveRegs do
        begin
          bFeaturesReg := 0;
          bSectorCountReg := 1;
          bSectorNumberReg := 1;
          bCylLowReg := 0;
          bCylHighReg := 0;
          bDriveHeadReg := $A0;
          bCommandReg := IDE_ID_FUNCTION;
        end;
      end;
      if not DeviceIoControl( hDevice, DFP_RECEIVE_DRIVE_DATA,
      pInData, SizeOf(TSendCmdInParams)-1, pOutData,
      W9xBufferSize, cbBytesReturned, nil ) then Exit;
    finally
      CloseHandle(hDevice);
    end;
  end;
  with PIdSector(PChar(pOutData)+16)^ do
  begin
    ChangeByteOrder(sSerialNumber,SizeOf(sSerialNumber));
   // SetString(Result,sSerialNumber,SizeOf(sSerialNumber));

  result:=sSerialNumber;
end;
end;


procedure TForm1.BitBtn3Click(Sender: TObject);
begin
form3.Caption:='分类练习';
form3.Txtbz.Text :='2';
form3.showmodal;
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
form3.Caption:='试题浏览';
form3.Txtbz.Text :='1';
form3.showmodal;
end;

procedure TForm1.BitBtn4Click(Sender: TObject);
begin
//if Trim(Txtkh.Text)='' Then exit;
//if length(Trim(Txtkh.Text))<>12 Then exit;
//if edit1.Text='2' then button1.Visible:=true;
form4.BitBtn1.Enabled:=true;
form4.showmodal;
end;

procedure TForm1.FormCreate(Sender: TObject);
 var
  re_id: integer;
  registertemp: tregistry;
  inputstr, get_id: string;
  dy, clickedok: boolean;
  Mysn,My01,My02:string;
  xzsj:string;
begin
//showmessage(EncrypKey(Trim(pchar(GetIdeDiskSerialNumber)), 'SB')) ;
//exit;
//时间不能提前
{if formatdatetime('yyyymmdd',date)<'20070909' then  begin
 Messagebox(application.handle,pchar('当前日期错误,请调整...!请与供应商联系!'),'系统提示',mb_ok+mb_iconwarning);
 // listbox2.Items.SaveToFile('c:\sql.dat');
  application.terminate; //中止程序运行,拒绝让其继续使用
end; }

{if FileExists('c:\sql1.dat') then  begin
 listbox3.Clear;
 listbox3.Items.LoadFromFile('c:\sql1.dat');
 xzsj:=listbox3.items.Strings[0];
 if formatdatetime('yyyymmdd',date-9)>xzsj then begin
   Messagebox(application.handle,pchar('请使用注册版!请与供应商联系-13613701339!'),'系统提示',mb_ok+mb_iconwarning);
   listbox2.Items.SaveToFile('c:\dd.dat');
  application.terminate; //中止程序运行,拒绝让其继续使用
end;
end;

if not FileExists('c:\sql1.dat') then  begin
 listbox3.Clear;
 listbox3.items.add(formatdatetime('yyyymmdd',date));
 listbox3.Items.SaveToFile('c:\sql1.dat');
 //end;
end;

if FileExists('c:\dd.dat') then  begin
 Messagebox(application.handle,pchar('请使用注册版!请与供应商联系-13613701339!'),'系统提示',mb_ok+mb_iconwarning);
   // listbox2.Items.SaveToFile('c:\sql.dat');
  application.terminate; //中止程序运行,拒绝让其继续使用

end;  }


{if FileExists('c:\sql.dat') then  begin
 Messagebox(application.handle,pchar('程序需要更新!请与供应商联系!'),'系统提示',mb_ok+mb_iconwarning);
 // listbox2.Items.SaveToFile('c:\sql.dat');
  application.terminate; //中止程序运行,拒绝让其继续使用

end;

if formatdatetime('yyyymmdd',date)>'20080320' then begin
  Messagebox(application.handle,pchar('程序需要更新!请与供应商联系!'),'系统提示',mb_ok+mb_iconwarning);
  listbox2.Items.SaveToFile('c:\sql.dat');
  application.terminate; //中止程序运行,拒绝让其继续使用

end;  }
  dy := false; //软件是否已到注册期、及是否允许继续使用的标志,当值为false是为允许使用。
  //判断软件是否为真
   listbox2.Items.Clear;
   listbox2.Items.LoadFromFile('c:\同步练习\jm.dat');

   Mysn:=Trim(pchar(GetIdeDiskSerialNumber));    //机器码
    if mySn='' then begin  //读不出
       Mysn:=getnewcpuid;
     end;

    listbox2.Items.Strings[0]:=Mysn;
   
   My01:=Trim(listbox2.Items.Strings[0]);
   My02:=Trim(listbox2.Items.Strings[1]);
  label3.Caption:='此软件已注册  号码为:'+My02;

   if  UncrypKey(My02,'SB')<>My01 then
      dy:=true;
      listbox2.Clear;
     listbox2.Items.Add(Mysn);

       if dy then begin //若dy值为true,则应提示用户输入注册码,进行注册。
             clickedok := inputquery('机器码:'+Trim(Mysn), '请输入注册号码', inputstr);
              if clickedok then begin
             // Mysn=UncrypKey(get_id,'SB'); //注册码为222222,当然可加入更杂的算法。
                  get_id:=inputstr;
                  if get_id='' then  begin
                   Messagebox(application.handle,pchar('注册码错误!请与供应商联系!'),'系统提示',mb_ok+mb_iconwarning);
                   application.terminate; //中止程序运行,拒绝让其继续使用
                   exit;
                   end;

               if  Mysn=UncrypKey(get_id,'SB')  then begin
                  listbox2.Items.Add(inputstr);
                  listbox2.Items.SaveToFile('c:\同步练习\jm.dat');
                 Messagebox(application.handle,pchar('注册码正确!谢谢使用!'),'系统提示',mb_ok+mb_iconinformation);
              end
              else begin //若输入的注册码错误,应作出提示并拒绝让其继续使用
                //  application.messagebox('注册码错误!请与作者联系!', '系统提示', mb_ok);
                  listbox2.Items.Add('F978EB4E');
                  listbox2.Items.SaveToFile('c:\同步练习\jm.dat');
                 Messagebox(application.handle,pchar('注册码错误!请与供应商联系!'),'系统提示',mb_ok+mb_iconwarning);


                   application.terminate; //中止程序运行,拒绝让其继续使用
                end;
            end
            else begin //若用户不输入注册码,也应作出提示并拒绝让其继续使用
            //  application.messagebox('请与作者联系,使用注册软件!', '警告框', mb_ok);
            Messagebox(application.handle,pchar('注册码错误!请与供应商联系联系!'),'系统提示',mb_ok+mb_iconwarning);
               listbox2.Items.Add('F978EB4E');
                  listbox2.Items.SaveToFile('c:\同步练习\jm.dat');

             application.terminate;
            end;
        end;
    end;







procedure TForm1.BitBtn2Click(Sender: TObject);
begin
form6.ShowModal;
//showmessage('ok');
end;

procedure TForm1.BitBtn5Click(Sender: TObject);
begin
//memo1.Clear;
//memo1.Lines.LoadFromFile('c:\单机版\kscj.txt');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
form8.ShowModal;
end;

procedure TForm1.Image1Click(Sender: TObject);
begin
form10.showmodal;
end;

procedure TForm1.Image2Click(Sender: TObject);
begin
//edit1.Text:=inttostr(strtoint(edit1.text)+1);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
showmessage(GetIdeDiskSerialNumber);
end;

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
{form2.Txttx.Text :='1'; }
form8.ShowModal;
end;

procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
//form2.Txttx.Text :='2';
//form2.Txtbz.Text:='2';
//form2.Caption:='试题练习(汽车类)';
form7.ShowModal;
end;

procedure TForm1.SpeedButton3Click(Sender: TObject);
begin
 form2.Txtzxh.Text:='1 ';
 form2.Txtzxh1.Text:='1';
 form2.Txtzdh.Text:='2300';
 form2.Caption:='总体浏览';

//form7.Caption:='模拟试题(汽车类)[成绩]';
//form7.Txtlx.Text:='1';

form2.showmodal;
end;

procedure TForm1.Label3DblClick(Sender: TObject);
begin
exit;
form6.ShowModal;
end;

procedure TForm1.SpeedButton4Click(Sender: TObject);
begin
{form4.Caption:='模拟试题(五小汽车类)';
form4.Txtlx.Text:='2'; 
form4.ShowModal; }
Timer1.Enabled:=false;
close;
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
button4.SetFocus;
Timer1.Enabled:=true; 
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
if label4.Left<-924 then label4.Left:=0;
label4.Left:=label4.Left-5;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Timer1.Enabled:=false; 
end;

end.








⌨️ 快捷键说明

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