Burning DVD Disc Example for Visual Basic

' The following code demonstrates how to burn a DVD disc using the LEAD Multimedia toolkit:

Option Explicit

Dim gLDVDBurner As LTDVDBurner

 

'' Burn Disc Button handler

Private Sub btnBurnDisc_Click()

   On Error GoTo BurnDiscError
 

   '' Check DVD burner count
Dim lCount As Long

   lCount = gLDVDBurner.DriveCount
If lCount < 1 Then

      MsgBox "No DVD Writers installed on this computer.  Operation cancelled"
 Exit Sub

   End If

'' Set current DVD writer drive number
gLDVDBurner.CurrentDrive = 0
 

'' Load DVD Disc
gLDVDBurner.LoadDisc()

'' Check if Drive is writeable
If Not gLDVDBurner.Writeable Then
 MsgBox "Selected drive is not writeable.  Operation cancelled"
 Exit Sub
End If

'' Check the DVD burner speeds available

lCount = gLDVDBurner.SpeedCount
If lCount < 1 Then
 MsgBox "No DVD Writer speeds available.  Operation cancelled"
 Exit Sub
End If
 

   '' Set Autoeject property

   gLDVDBurner.AutoEject = true

 

   '' Set the writer speed
gLDVDBurner.CurrentSpeed = gLDVDBurner.SpeedCount - 1
 

   '' Set the input folder path containing files to burn

   gLDVDBurner.InputPath = "C:\MyDVDFiles"

'' Set the disc volume label

   gLDVDBurner.VolumeName = "DVD Files"


'' Burn it

   gLDVDBurner.Write()
 

   Exit Sub

BurnDiscError:

      MsgBox Str(Err.Description) + "occurred. Operation cancelled."

   Exit Sub

End Sub


'' Cancel Button handler
Private Sub btnClose_Click()

   Dim lstate As Long

   lstate = gLDVDBurner.State
 

   If lstate <> LTDVDBurner_State_Idle Then

      If MsgBox("A disc operation is currently in progress. Are you sure you would like to exit?", vbYesNo) <> vbYes Then

         Exit Sub

      End If
 

      gLDVDBurner.Cancel

 

  End If

End Sub