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

📄 unit1.cpp

📁 刻录机源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
              Function      bReadyClick()
              Description  =  Checks if the Device is ready or Not
*******************************************************************************/

void __fastcall TForm1::bReadyClick(TObject *Sender)
{
  if ( mcdb->TestUnitReady(5000))
  {
  mcdb->DebugMsg(">>> DRIVE IS READY", 0);
  }
  else
  {
  mcdb->DebugMsg(">>> DRIVE IS NOT READY ", 0);
  }

}
/*******************************************************************************
              Function        AddFilesToCD()
              Description  =  Add Files to the CD Drive
                             --  if import session is true then import the
                                 session otherwise
                             --  check for file path and directory path and add
                                 it to the CD.
*******************************************************************************/

TForm1::AddFilesToCD()
{
  int i;
  int Entries = 1;
  String fPath, fName;
  if (SessionToImport != 0)
  {
    mcdb->SessionToImport = 0;
    mcdb->ImportSession(SessionToImport, NULL);
  }
  Entries = clBox->Items->Count;
  if (Entries < 1 )
  {
    ShowMessage("Atleast one file/directory should be selected");
    return 0;
  }
  for (i=0;i<Entries;i++)
  {
    fPath = ExtractFilePath(clBox->Items->Item[i]->SubItems[0].Text);
    fName = ExtractFileName(clBox->Items->Item[i]->SubItems[0].Text);
    if (cPathInfo->State == cbGrayed)
    {
      mcdb->ParentDirectoryOnly = true;
      if (DirectoryExists(clBox->Items->Item[i]->SubItems[0].Text))
        mcdb->InsertDir(mcdb->RootDir, fPath, "*.*", faAnyFile,
                clBox->Items->Item[i]->Checked, true, oArchiveFiles);
      else
        mcdb->InsertFile("\\", fPath + fName , true);
    }
    else
    {
      mcdb->ParentDirectoryOnly = false;
      if ( DirectoryExists(fPath) )
        mcdb->InsertDir(mcdb->RootDir, fPath, "*.*", faAnyFile,
         clBox->Items->Item[i]->Checked, cPathInfo->Checked, oArchiveFiles);
      else
        mcdb->InsertFile("\\", fPath+fName, cPathInfo->Checked);
    }
  }
  //mcdb->RemoveEmptyDirs();
  return 0;
}
/*******************************************************************************
              Function       Clear()
              Description  =  clears the selected file s
*******************************************************************************/

void __fastcall TForm1::bClearClick(TObject *Sender)
{
  int nMaxFiles, nMaxDirs;
  clBox->Items->Clear();
  nMaxFiles = MaxFiles;
  nMaxDirs  = MaxDirs;
  mcdb->ClearAll(nMaxFiles, nMaxDirs);
}
/*******************************************************************************
              Function     bSaveISOClick(TObject *Sender)
              Description  =   Saves the Selected files and directories in ISO
                               Image Format file
                            -- Get the ISO file name
                            -- if the files and directories not selected thenn Exit
*******************************************************************************/

void __fastcall TForm1::bSaveISOClick(TObject *Sender)
{
  String FileName;
  FileName = mcdb->ISOFileName;
  if (InputQuery("Build ISO","Enter ISO File Name to build", FileName))
  {
    Timer1->Enabled  = true;
    mcdb->ClearAll(MaxFiles, MaxDirs);
    AddFilesToCD();
    if ( (mcdb->DirsCount == 0) && (mcdb->FilesCount == 0) )
      return;
    mcdb->DebugMsg(">>> ADD FILES/DIRS TO .ISO DONE.", 0);
    Application->ProcessMessages();
    mcdb->DebugMsg(">>> START BUILDING .ISO FILE", 0);
    pTop->Enabled = false;
    pTop2->Enabled = false;
    bSaveISO->Enabled = false;
    bBurnISO->Enabled = false;
    DriveCB->Enabled = false;
    mcdb->Prepare(true, NULL);
    pcd->Max = mcdb->ImageSize;
    lSize->Caption = FormatFloat("#,##0.00", mcdb->ImageSize * 2048 / (1024 * 1024))+" MB";
    mcdb->SaveToISOFile(FileName,QuickSaveISO);

  }
}
/*******************************************************************************
              Function        bCEraseClick(TObject *Sender)
              Description  =  check if the cd is erasable then completely erase
                              the data on the Disc
*******************************************************************************/

void __fastcall TForm1::bCEraseClick(TObject *Sender)
{
 if (!(mcdb->Erasable()))
    ShowMessage("Disc is not Erasable");
  else
  if ( Application->MessageBox("All Data on the CD will be lost", "Want to Complete Erase the Disc ? (may take 10-70 mins)", MB_DEFBUTTON2+MB_ICONWARNING+MB_YESNO) == ID_YES )
  {
    Timer1->Enabled = true;
    mcdb->WriteSpeed = GetSpeed(cbSpeed->Items[cbSpeed->ItemIndex].Text);
    mcdb->EraseDisc(etComplete);
  }
}
/*******************************************************************************
            Function       mcdbAddDir(TObject *Sender, AnsiString &LongName,
                                    AnsiString &ShortName, bool &Skip)
            Description  =     Check if the directory size is greater than 127
                               then skip that directory other wise add the directory

*******************************************************************************/

void __fastcall TForm1::mcdbAddDir(TObject *Sender, AnsiString &LongName,
      AnsiString &ShortName, bool &Skip)
{
  // be very carefull to change the dir names
  if ( UpperCase(Name) == "RECYCLED" )
  {
    mcdb->DebugMsg(">>> SKIPING RECYCLE BIN", 0);
    Skip = true;
  }
  if ( ( Name.Length() ) > 127 )
  {
    mcdb->DebugMsg(">>> SKIPING INVALID FILE NAME (LENGTH OF FILE NAME MUST BE LESS THAN 64)", 0);
    mcdb->DebugMsg("     " + Name, 0);
    Skip = true;
  }
}
/*******************************************************************************
              Function        bCapsClick(TObject *Sender)
              Description  =  Displays the Device capabilities in the Seperate
                              form.
*******************************************************************************/
void __fastcall TForm1::bCapsClick(TObject *Sender)
{
  Form2 = new TForm2(this);

  Form2->ReadCDR->Checked     =   mcdb->DeviceCapabilities.Contains(dcReadCDR);
  Form2->ReadCDRW->Checked    =   mcdb->DeviceCapabilities.Contains(dcReadCDRW);
  Form2->ReadDVD->Checked     =   mcdb->DeviceCapabilities.Contains(dcReadDVD);
  Form2->ReadDVDR->Checked    =   mcdb->DeviceCapabilities.Contains(dcReadDVDR);
  Form2->ReadDVDRAM->Checked  =   mcdb->DeviceCapabilities.Contains(dcReadDVDRAM);
  Form2->WriteCDR->Checked    =   mcdb->DeviceCapabilities.Contains(dcWriteCDR);
  Form2->WriteCDRW->Checked   =   mcdb->DeviceCapabilities.Contains(dcWriteCDRW);
  Form2->WriteDVDR->Checked   =   mcdb->DeviceCapabilities.Contains(dcWriteDVDR);
  Form2->WriteDVDRAM->Checked =   mcdb->DeviceCapabilities.Contains(dcWriteDVDRAM);
  Form2->WriteTest->Checked   =   mcdb->DeviceCapabilities.Contains(dcWriteTest);
  Form2->UnderrunProtection->Checked = mcdb->DeviceCapabilities.Contains( dcUnderrunProtection );
  Form2->Label1->Caption   = "  " + mcdb->Device;
  Form2->Label2->Caption   = "Max Write Speed   :  " + FormatFloat("0x", mcdb->DeviceMaxWriteSpeed);
  Form2->Label3->Caption     = "Max Read Speed    :  " + FormatFloat("0x", mcdb->DeviceMaxReadSpeed);
  Form2->ShowModal();

}
/*******************************************************************************
              Function  () Performs This
              Description  =
*******************************************************************************/
void __fastcall TForm1::clBoxDragDrop(TObject *Sender, TObject *Source,
      int X, int Y)
{
  int i;
  String tmp;
  __int64 size;

  TListItem* tmpItem;


  if( Sender->ClassNameIs("TListView") && Source->ClassNameIs("TDirectoryListBox"))
  {
    tmp = lbDir->GetItemPath(lbDir->ItemIndex);
    if ( tmp[tmp.Length()] ==  '\\' )
    {
        tmp = tmp.SubString(0,tmp.Length()-1);
    }
    clBox->Items->Add();
    tmpItem = clBox->Items->Item[clBox->Items->Count-1];
    size = mcdb->GetDirSize( tmp + '\\');
    tmpItem->SubItems->Add(tmp + '\\');
    tmpItem->SubItems->Add(FormatFloat("#,##", size));
    tmpItem->Checked = true;
  }
  if ((Sender->ClassNameIs("TListView"))&& (Source->ClassNameIs("TFileListBox")) )
  {
    for (i=0;i < lbFiles->Items->Count; i++)
    {
      if (lbFiles->Selected[i])
      {
        tmp = lbDir->Directory;
        if ( tmp[tmp.Length()] == '\\' )
        {
           tmp = tmp.SubString(0,tmp.Length()-1);
        }
        tmp = tmp + '\\' + ExtractFileName(lbFiles->FileName);
        clBox->Items->Add();
        tmpItem = clBox->Items->Item[clBox->Items->Count-1];
        size  = mcdb->GetDirSize(tmp);
        tmpItem->SubItems->Add(tmp);
        tmpItem->SubItems->Add(FormatFloat("#,##", size));
      }
    }
  }
}
/*******************************************************************************
              Function       cbSpeedDropDown(TObject *Sender)
              Description  =  checks and sets the Speed of the device

********************************************************************************

*/
void __fastcall TForm1::cbSpeedDropDown(TObject *Sender)
{
  int  li;
  int  ms;
  int Speeds;
  int ActSpd;
  String Str;
  int Divider, Medium;

  Medium = mcdb->DiscType();
  if (Medium >= mtDVD_ROM)
  {
    Divider = 1385;
  }
  else
  {
    Divider = 176.4;
  }
  li = cbSpeed->ItemIndex;
  cbSpeed->Items->Clear();
  cbSpeed->Items->Add("Max");
  ms = mcdb->MaxWriteSpeed();
  Speeds = ms;
  while ( Speeds > 0 )
  {
    mcdb->WriteSpeed = Speeds;
    ActSpd = mcdb->CurrentWriteSpeed();
    if ( ( ActSpd / Divider ) < 10 )
      Str = FormatFloat("0.0X ", ActSpd / Divider) + FormatFloat("(#,##0 KB/s)", ActSpd);
    else
      Str = FormatFloat("0X ", ActSpd / Divider)+FormatFloat("(#,##0 KB/s)", ActSpd);
    if ( cbSpeed->Items->IndexOf( Str ) < 0 )
        cbSpeed->Items->Add(Str);
    if (Medium >= mtDVD_ROM)
    {
       Speeds -= 1385;
    }
    else
    {
       Speeds -= 176.4;
    }

  }
  if (li == -1)
    cbSpeed->ItemIndex = 0;
  else
    if (li <= cbSpeed->Items->Count)
      cbSpeed->ItemIndex = li;
    else
      cbSpeed->ItemIndex = 0;
}
/*******************************************************************************
              Function      ClearAll1Click(TObject *Sender)
              Description  =   Clear all the messages in the Debug window
*******************************************************************************/

void __fastcall TForm1::ClearAll1Click(TObject *Sender)
{
    Memo1->Lines->Clear();
}

/*******************************************************************************
              Function         mcdbEraseDone(TObject *Sender, bool WithError)
              Description  =   this event will be called when the erase process
                               finishes.
                               And if the eject is true then ejects the Medium.
*******************************************************************************/
void __fastcall TForm1::mcdbEraseDone(TObject *Sender, bool WithError)
{
  if (WithError)
    mcdb->DebugMsg(">>> ERASE PROCESS DONE WITH ERROR", 0);
  else
    mcdb->DebugMsg(">>> ERASE PROCESS DONE", 0);
  Timer1->Enabled = false;

  if ( (!(WithError)) && (ccEject) )
    mcdb->LoadMedium(true);
  pcd->Position = 0;
  MessageBeep(MB_OK);
  mcdb->DebugMsg(" ", 0);

}
/*******************************************************************************

⌨️ 快捷键说明

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