gusucode.com > Delphi刻录软件源码程序 > Delphi刻录软件源码程序/ym_MagicCDDVDBurnerVCL-hicode/Examples/FullDemoC/Unit1.cpp
#include <vcl.h> #pragma hdrstop #include <math.h> #include <stdio.h> #include "Unit1.h" #include "Unit2.h" #include "ImportSession.h" #include "ConfigurationSettings.h" #include "DiscLayout.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "mbCDBC" #pragma link "mbDrvLib" #pragma link "mbExDD" #pragma resource "*.dfm" TForm1 *Form1; byte buf[65536]; WORD GetSpeed(String ss) { int Divider, Medium; if (ss == "Max") { return 0; } else { Medium = Form1->mcdb->DiscType(); if ( Medium >= mtDVD_ROM ) { Divider = 7; } else { Divider = 1; } return StrToInt( ss[ ss.Pos("X") - 1 ] ) * Divider; } } __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } void __fastcall TForm1::Panel12Resize(TObject *Sender) { DriveCB->Width = Panel2->Width - bNetwork->Width-4; } /******************************************************************************* Function = clBoxDragOver Description = Tell the system which files to accept by checking the source. If the dragged item is either from the File List or Directory List Box or from the Shell Accept it other wise dont accept it. *******************************************************************************/ void __fastcall TForm1::clBoxDragOver(TObject *Sender, TObject *Source, int X, int Y, TDragState State, bool &Accept) { Accept = Source->ClassNameIs("TDirectoryListBox") || Source->ClassNameIs("TFileListBox"); } /******************************************************************************* Function = FormShow Description = Initializes the form Settings 1. Check and display For Trial Version. 2. Initialize ASPI. 3. Display all the Devices. 4. Display the speed. 5. initilaize the MCDB. *******************************************************************************/ void __fastcall TForm1::FormShow(TObject *Sender) { int i; // counter for Temporary Work String State; // State of the System TIniFile* ini; // initialzation File if (TrialMCDB) { Caption = Caption + " (TRIAL VERSION)"; } mcdb->DebugMsg(">>> " + Caption, 0); mcdb->InitializeASPI(true, ""); if (!(mcdb->ASPIInitialized)) { pTop->Enabled = false; pTop2->Enabled = false; ShowMessage("Error initializing ASPI Layer, Please visit support page, http://forum.binarymagics.com for more information"); return; } cbSpeedDropDown(Sender); if ( (mcdb->Devices != NULL) && (mcdb->Devices->Count > 0) ) { cbDrives->Items->Assign(mcdb->Devices); cbDrives->ItemIndex = 0; cbDrivesChange(Sender); } oArchiveFiles = true; oImportSession = true; State = "CHECKED2q"; if ( UpperCase(State) == "GRAYED" ) cPathInfo->State = cbGrayed; else if (UpperCase(State) == "CHECKED") cPathInfo->State = cbChecked; else cPathInfo->State = cbUnchecked; mcdb->DebugMsg(" ", 0); ini = new TIniFile("MCDB.INI"); oArchiveFiles = ini->ReadBool("Options", "ArchiveFiles", oArchiveFiles); oImportSession = ini->ReadBool("Options", "ImportSession", oImportSession); State = ini->ReadString("Options", "SavePath", ""); if (UpperCase(State) == "GRAYED") cPathInfo->State = cbGrayed; else if (UpperCase(State) == "CHECKED") cPathInfo->State = cbChecked; else cPathInfo->State = cbUnchecked; mcdb->FinalizeDisc = ini->ReadBool("Options", "CloseDisc", mcdb->FinalizeDisc); mcdb->JolietFileSystem = ini->ReadBool("Options", "JolietFS", mcdb->JolietFileSystem); mcdb->TestWrite = ini->ReadBool("Options", "TestWrite", mcdb->TestWrite); mcdb->PerformOPC = ini->ReadBool("Options", "PerformOPC", mcdb->PerformOPC); QuickSaveISO = ini->ReadBool("Options", "QuickSaveISO", QuickSaveISO); if (ini->ReadBool("Options", "ImportSession", false) == true) SessionToImport = ini->ReadInteger("Options", "SessionNo", mcdb->SessionToImport); else SessionToImport = 0; ccEject = ini->ReadBool("Options", "EjectDisc", False); ccShowFiles = ini->ReadBool("Options", "ShowFiles", False); ccImportSession = ini->ReadBool("Options", "ImportSession", False); mcdb->BootImage = ini->ReadString("Options", "BootImage", mcdb->BootImage); mcdb->IdVolume = ini->ReadString("Options", "VolumeLable", mcdb->IdVolume); mcdb->CacheSize = ini->ReadInteger("Options", "CacheSize", mcdb->CacheSize); delete ini; } /******************************************************************************* Function bBurnClick Description = Burn the CD = Steps 1. Read buffer capacity of the device. 2. Set The Speed 3. Proces the Message So That Application Should Not Go Idle. 4. Check If the Dir Count and File Count is 0 then do nothing. 5. Add Files To CD 6. if Show Files is True then Show Files in the Form 7. Prepares data for burning on the media or for Saving to .ISO file. 8. Start burning the cd. *******************************************************************************/ void __fastcall TForm1::bBurnClick(TObject *Sender) { unsigned int a; // temporary Variables For Results unsigned int b; String msg; mcdb->ReadBufferCapacity(a, b); pHBuf->Max = a; if ( cbSpeed->ItemIndex == -1) cbSpeed->ItemIndex = 0; mcdb->WriteSpeed = GetSpeed(cbSpeed->Text); Application->ProcessMessages(); mcdb->ClearAll(MaxFiles,MaxDirs); AddFilesToCD(); mcdb->DebugMsg(">>> ADD FILES/DIRS TO CD DONE.", 0); Application->ProcessMessages(); if ((mcdb->DirsCount == 0) && (mcdb->FilesCount == 0)) { return; }; if (ccShowFiles) { frmDiscLayout = new TfrmDiscLayout(this); frmDiscLayout->ShowModal(); } mcdb->Prepare(false, NULL); pcd->Max = mcdb->ImageSize; if ( (TrialMCDB) && (mcdb->ImageSize > 65024 ) ) { msg = "You can not write more than 127 MB in trial version of this software \n Only first 127 MB out of "+ FormatFloat("#,##0.00", (double )(mcdb->ImageSize * 2048 / (1024 * 1024)))+ " MB will be usable \n still want to continue ?"; if ( Application->MessageBox(msg.c_str(), "This is a size limited TRIAL VERSION", MB_DEFBUTTON1+MB_ICONSTOP+MB_YESNO) == ID_YES ) goto okDoBurn; else { Timer1->Enabled = false; return; } } msg = "Start Writing " + FormatFloat("#,##0.00\0", (double )(mcdb->ImageSize * 2048.0 / (1024.0 * 1024.0)))+" MB"; if (Application->MessageBox(msg.c_str(), "Want to Burn the CD ?", MB_DEFBUTTON1+MB_ICONQUESTION+MB_YESNO) == ID_YES) { okDoBurn: bAbort->Visible = true; Timer1->Enabled = true; mcdb->DebugMsg(">>> STARTING BURNCD ON " + mcdb->Device, 0); pTop->Enabled = false; pTop2->Enabled = false; bBurnISO->Enabled = false; bSaveISO->Enabled = false; DriveCB->Enabled = false; mcdb->BurnCD(); } else Timer1->Enabled = false; } /******************************************************************************* Function Timer1Timer Description = This function Will Set the Progress bar and Displays the Messages at a fixed interval of time as they are progressed. *******************************************************************************/ void __fastcall TForm1::Timer1Timer(TObject *Sender) { if ( !(mcdb->Erasing)) { lSize->Caption = FormatFloat("#,##0.00", ((double )mcdb->BytesWritten / (1024.0 * 1024.00)))+"/"+FormatFloat("#,##0.00", ((double )(mcdb->ImageSize * 2048.0) / (1024.0 * 1024.0)))+ " MB "; pBuf->Position = mcdb->BufferProgress(); pcd->Position = mcdb->BytesWritten / 2048; if (mcdb->DeviceBufferSize >= mcdb->DeviceFreeBufferSize) { pHBuf->Position = (int) (mcdb->DeviceBufferSize - mcdb->DeviceFreeBufferSize); } } else { pcd->Max = 100; pcd->Position = mcdb->EraseProgress(); }; } /******************************************************************************* Function cbDrivesChange Description = Drive Combo Box Changes Check The capabilities of the Drive and Set the Burn Button Enable or Disable. *******************************************************************************/ void __fastcall TForm1::cbDrivesChange(TObject *Sender) { char Letter; char buffer[32]; mcdb->Device = cbDrives->Text; cbDrives->Hint = cbDrives->Text; Letter = mcdb->DeviceByDriveLetter; if ( Letter == '\0') { lDrive->Caption = " Drive :"; } else { sprintf(buffer, "Drive %c: ", Letter); lDrive->Caption = buffer; // ,Letter); // convert it later } if ( ( mcdb->DeviceCapabilitiesA.Contains(dcWriteCDR)) ||(mcdb->DeviceCapabilitiesA.Contains(dcWriteDVDR)) || (mcdb->DeviceCapabilitiesA.Contains(dcWriteDVDRAM)) ) bBurn->Enabled = true; else bBurn->Enabled = false; } /******************************************************************************* Function bQEraseClick() Description = check if the Disc is Erasable or not Then Erase the Data on the disc *******************************************************************************/ void __fastcall TForm1::bQEraseClick(TObject *Sender) { if ( !(mcdb->Erasable() ) && ( mcdb->DiscType() != mtDVD_RAM ) ) { ShowMessage("Disc is not Erasable"); } else if ( Application->MessageBox("All Data on the CD will be lost", "Want to Quick Erase the Disc ?", MB_DEFBUTTON2+MB_ICONWARNING+MB_YESNO) == ID_YES) { Timer1->Enabled = true; mcdb->WriteSpeed = GetSpeed(cbSpeed->Text); mcdb->EraseDisc(etQuick); } } /******************************************************************************* Function Load Medium Description = Loads the Medium (e.g closes the CD tray if it is outside) *******************************************************************************/ void __fastcall TForm1::bLoadClick(TObject *Sender) { if (mcdb->LoadMedium(false)) { mcdb->DebugMsg(">>> LOAD MEDIUM COMMAND DONE.", 0); } } /******************************************************************************* Function Ejects Description = Ejects The (C D/DVD etc) drive tray *******************************************************************************/ void __fastcall TForm1::bEjectClick(TObject *Sender) { mcdb->FlushCache(10000, false); mcdb->LockMedium(true); if (mcdb->LoadMedium(true)) mcdb->DebugMsg(">>> EJECT MEDIUM COMMAND DONE.", 0); else mcdb->DebugMsg(">>> EJECT MEDIUM COMMAND FAILED.", 0); } /******************************************************************************* 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); } /******************************************************************************* Function bDiscClick Description = Displays the Disc Information details in the Other form get the Disc Information From the First Completed track to the Last Completed Tracks. *******************************************************************************/ void __fastcall TForm1::bDiscClick(TObject *Sender) { Mbdrvlib::TDisc Disc; unsigned int i, ii; unsigned long int a, b; unsigned int fb, ub, tb; TVolumeDescriptor vd; String str; byte bs; frmSession = new TfrmSession(this); frmSession->lb->Items->Clear(); Disc = mcdb->GetDiscInformation(); if (!(Disc.Valid) ) { frmSession->lb->Items->Add(" Error getting session information"); frmSession->ShowModal(); return; } bs = mcdb->SessionsOnDisc() + 1; mcdb->ReadTrackInformation(bs); { for(i = mcdb->Disc.FirstCompleteSession ;i <= mcdb->Disc.LastCompleteSession; i++) { memset(buf, 0,sizeof(buf)); if ( mcdb->ReadTOC(0, buf, 248, i, true, false)) a = MSF2LBA(0, buf[9], buf[10], buf[11]); else a = 0; if (a != 0 ) { a = a - 150; str =IntToDec(buf[9], 3, " ")+':'+ IntToDec(buf[10], 2, "0")+':'+IntToDec(buf[11], 2, "0"); mcdb->ReadTrackInformation(i); for (ii=16 ; ii<=16; ii++) { if ( mcdb->Read10(a+ii, 1, (char *)&vd, 2048) ) if (vd.NoOfSectors != 0) { b = ceil(mcdb->TrackInformation.TrackSize * 2048 / 1024 / 1024); frmSession->lb->Items->Add(" "+IntToDec(i, 3, " ")+ " "+str+" "+IntToDec(b, 4, " ")+" MB"); goto found; } } frmSession->lb->Items->Add(" "+IntToDec(i, 3, " ")+ " "+str+" ???? MB"); found: } } } str = " "; if (mcdb->ReadTOC(0, buf, 248, 0xAA, true, false) ) { str =IntToDec(buf[9], 3, " ")+ ":"+ IntToDec(buf[10], 2, " ")+":"+IntToDec(buf[11], 2, " "); } else str ="00:00:00"; fb = mcdb->FreeBlocksOnDisc(); frmSession->lb->Items->Add(" Free " + str + " "+IntToDec(ceil((fb / 1024 / 1024)*2048), 4," ")+" MB"); Disc = mcdb->GetDiscInformation(); frmSession->lMedium->Caption = DiscTypeString[mcdb->DiscType()]; ub = mcdb->UsedBlocksOnDisc(); tb = mcdb->TotalBlocksOnDisc(); frmSession->lDiscSize->Caption = FormatFloat("#,##0.00 MB", (double )tb / 1024.0 / 1024.0 * 2048.0 ); frmSession->lUsedSpace->Caption = FormatFloat("#,##0.00 MB", (double )ub / 1024.0 / 1024.0 * 2048.0 ); frmSession->Visible = false; frmSession->ShowModal(); } /******************************************************************************* Function mcdbWriteDone Description = This Event handler is called after the write process is done. It Checks for the error Messages if they are Present Then Give the Message. if Successfully Completed then Ejects the Medium. *******************************************************************************/ void __fastcall TForm1::mcdbWriteDone(TObject *Sender, AnsiString Error) { Timer1->Enabled = false; pTop->Enabled = true; pTop2->Enabled = true; bSaveISO->Enabled = true; bBurnISO->Enabled = true; DriveCB->Enabled = true; Timer1Timer(Sender); if (!(Error.IsEmpty())) { mcdb->DebugMsg(">>> WRITE/BURNCD PROCESS DONE WITH ERROR", 0); mcdb->DebugMsg(">>> " +Error, 0); } else { mcdb->DebugMsg(">>> WRITE/BURNCD PROCESS DONE", 0); if (oArchiveFiles) mcdb->ResetFilesArchiveBit(); } if ( (Error.IsEmpty()) && (ccEject) ) mcdb->LoadMedium(true); if (oArchiveFiles) mcdb->ResetFilesArchiveBit(); mcdb->ClearAll(MaxFiles, MaxDirs); MessageBeep(MB_OK); bAbort->Visible = False; mcdb->DebugMsg(" ", 0); } /******************************************************************************* Function Label1Click(TObject *Sender) Description = Opens the Web Site in The explorer Window. *******************************************************************************/ void __fastcall TForm1::Label1Click(TObject *Sender) { ShellExecute(ValidParentForm(this)->Handle,"open", "http://www.binarymagics.com", NULL, NULL, SW_SHOWNORMAL); } /******************************************************************************* Function mcdbFinalizingTrack (TObject *Sender) Description = Event Handler Foir Finalizinf the Track it Gives Error When the track is Finalizing *******************************************************************************/ void __fastcall TForm1::mcdbFinalizingTrack(TObject *Sender) { mcdb->DebugMsg(">>> FINALIZING TRACK", 0); } /******************************************************************************* Function Abort Operation Called Description = Abort the Current Operation. *******************************************************************************/ void __fastcall TForm1::bAbortClick(TObject *Sender) { mcdb->Abort(); bAbort->Visible = false; } /******************************************************************************* Function ExplorerDragDropDropped Description = Get the draged files from the Explorer. *******************************************************************************/ void __fastcall TForm1::ExplorerDragDropDropped(TObject *Sender, int ItemsCount) { int i; String tmp; __int64 size; TListItem *tmpItem; for (i = 0; i <ItemsCount ; i++ ) { tmp = ExplorerDragDrop->Items->Strings[i]; tmp = Trim(tmp); if (DirectoryExists(tmp)) { if ( tmp[tmp.Length()] != '\\' ) tmp = tmp + '\\'; 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; } else { 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 Remove1Click(TObject *Sender) Description = Removes the Selected File or Directory From The List of files & directories. *******************************************************************************/ void __fastcall TForm1::Remove1Click(TObject *Sender) { if (clBox->Selected != NULL) { clBox->Selected->Delete(); } } /******************************************************************************* Function mcdbAddFile Description = Add The Selected File *******************************************************************************/ void __fastcall TForm1::mcdbAddFile(TObject *Sender, const AnsiString FullPath, AnsiString &LongFileName, AnsiString &ShortFileName, TDateTime &DateTime, int Attr, __int64 FileSize, bool &Skip) { if ( FullPath != "" ) { try { TFileStream *fs = new TFileStream(FullPath, fmOpenRead+fmShareDenyNone); fs->Free(); } catch(...) { mcdb->DebugMsg(">>> SKIPING; FILE IS IN USE "+ FullPath, 0); } } if ( LongFileName.Length() > 107 ) { mcdb->DebugMsg(">>> SKIPING; FILE NAME LENGTH > 107 "+ FullPath, 0); Skip = true; } if (!(Skip)) { lSize->Caption = FormatFloat("#,##0.00", (mcdb->FilesSize) / (1024 * 1024))+" MB"; } } /******************************************************************************* Function BurnISOClick Description = Burn the *******************************************************************************/ void __fastcall TForm1::bBurnISOClick(TObject *Sender) { unsigned int a,b; if (od->Execute()) { mcdb->ReadBufferCapacity(a, b); pHBuf->Max = a; bAbort->Visible = true; Timer1->Enabled = true; mcdb->DebugMsg(">>> STARTING BURN .ISO IMAGE ON " + mcdb->Device, 0); pTop->Enabled = false; pTop2->Enabled = false; bSaveISO->Enabled = false; bBurnISO->Enabled = false; DriveCB->Enabled = false; Timer1->Enabled = true; mcdb->BurnISOImage(od->FileName); pcd->Max = mcdb->ImageSize; } } /******************************************************************************* Function cPathInfoClick Description = Path Info Click *******************************************************************************/ void __fastcall TForm1::cPathInfoClick(TObject *Sender) { TIniFile *ini; ini = new TIniFile( "MCDB.ini" ); String state; if (Form1->cPathInfo->State == cbChecked) state = "Checked"; else if (Form1->cPathInfo->State == cbGrayed) state = "Grayed"; else state = "Unchecked"; ini->WriteString("Options", "SavePath", state); delete ini; } /******************************************************************************* Function clBoxEditing Description = Dont allow the editing of the Files and Directories. ******************************************************************************** */ void __fastcall TForm1::clBoxEditing(TObject *Sender, TListItem *Item, bool &AllowEdit) { AllowEdit = false; } /******************************************************************************* Function bNetworkClick() Description = Get the Complete Network path *******************************************************************************/ void __fastcall TForm1::bNetworkClick(TObject *Sender) { String str; if (InputQuery("Network Path","Enter Complete Network path (\\Machine1\C)", str) ) { lbDir->Directory = str; } } void __fastcall TForm1::Button1Click(TObject *Sender) { bBurn->Enabled = true; } /******************************************************************************* Function Advance Click Description = Sets the advance and configuration Settings of the Burner Server. *******************************************************************************/ void __fastcall TForm1::bAdvanceClick(TObject *Sender) { frmSettings = new TfrmSettings(this); frmSettings->cEject->Checked = ccEject; frmSettings->cShowFiles->Checked = ccShowFiles; frmSettings->cImportSession->Checked = ccImportSession; frmSettings->ShowModal(); } void __fastcall TForm1::mcdbDebugMessage(TObject *Sender, AnsiString Message, BYTE mType) { Memo1->Lines->Add(Message); } //---------------------------------------------------------------------------