Multisession with vb

vbimport

#1

hello,
i use this code to make a multisession record with Vb but if i have burn folder1 and i would burn folder2 . I d’ont find the last session (folder1).

the code is below :

Public WithEvents nero As nero
Public drives As INeroDrives
Public WithEvents drive As NeroDrive
Public cnt As Integer
Public Folder As INeroFolder
Public strMessages As String
Dim fso As New FileSystemObject
Dim DriveFinished As Boolean

Private Sub btnAbort_Click()
nero.Abort
End Sub

Private Sub BuildFileFolderTree(ByRef nroFolderToUse As NeroFolder, folCurrent As Folder)
Dim folTMP As Folder
Dim filTMP As File
Dim nroFolTmp As NeroFolder
Dim nroFilTmp As NeroFile

For Each filTMP In folCurrent.Files
Set nroFilTmp = New NeroFile
nroFilTmp.Name = filTMP.Name
nroFilTmp.SourceFilePath = filTMP.Path
nroFolderToUse.Files.Add nroFilTmp
Next

For Each folTMP In folCurrent.SubFolders
Set nroFolTmp = New NeroFolder
nroFolTmp.Name = folTMP.Name
nroFolderToUse.Folders.Add nroFolTmp
Call BuildFileFolderTree(nroFolTmp, folTMP)
Next

End Sub
Private Sub Burn_Click()

btnAbort.Enabled = True
Burn.Enabled = False
Dim root, Folder As NeroFolder
Set root = New NeroFolder
Set Folder = New NeroFolder
Dim drives As INeroDrives
Set drives = nero.GetDrives(NERO_MEDIA_CDR)
Set drive = drives(AvailableDevices.ListIndex)
Dim isotrack As NeroISOTrack
Set isotrack = New NeroISOTrack
isotrack.Name = Text1.Text
isotrack.RootFolder = root

Dim speed As Variant
speed = Mid(Combo1.Text, 1, Len(Combo1.Text) - 1)
speed = CLng(Trim(speed))

Dim source As String
Dim fso As New FileSystemObject
source = Text2.Text
Folder.Name = fso.GetFolder(source).Name
root.Folders.Add Folder

Call BuildFileFolderTree(Folder, fso.GetFolder(source))

DriveFinished = False
drive.CDInfo NERO_READ_ISRC
While Not DriveFinished
X = DoEvents()
Wend
If NumExistingTracks > 0 Then
I = NumExistingTracks - 1
DriveFinished = False
drive.ImportIsoTrack I, NERO_IMPORT_ISO_ONLY
While Not DriveFinished
X = DoEvents()
Wend
End If

isotrack.BurnOptions = NERO_BURN_OPTION_CREATE_ISO_FS + NERO_BURN_OPTION_USE_JOLIET

drive.BurnIsoAudioCD "Pop Star", "Title", 0, isotrack, Nothing, Nothing, NERO_BURN_FLAG_WRITE + NERO_BURN_FLAG_CLOSE_SESSION, speed, NERO_MEDIA_CD

GoTo quit

handle_error:
strMessages = strMessages + Err.Description + Chr(13) + Chr(10) + nero.LastError
edtMessages = strMessages
quit:
End Sub
Private Sub effacer()
Command2.Enabled = False
Set Folder = New NeroFolder
Dim drives As INeroDrives
Set drives = nero.GetDrives(NERO_MEDIA_CDR)
Set drive = drives(AvailableDevices.ListIndex)
Dim isotrack As NeroISOTrack
Set isotrack = New NeroISOTrack
isotrack.Name = “”

isotrack.BurnOptions = NERO_BURN_OPTION_USE_JOLIET Or NERO_BURN_OPTION_CREATE_ISO_FS

Dim A
A = drive.CDRWErasingTime(True)
drive.EraseCDRW True

Command2.Enabled = True
GoTo quit:
handle_error:
strMessages = strMessages + Err.Description + Chr(13) + Chr(10) + nero.LastError
edtMessages = strMessages
quit:

End Sub

Private Sub Command1_Click()
Unload Me
End Sub

Private Sub Command2_Click()
effacer
End Sub

Private Sub Command4_Click()
Text2.Text = List1.Text
End Sub

Private Sub Command3_Click()

Text2.Text = Dir1.Path

Dim f As Folder, s As Long
Dim ch As String

ch = Dir1.Path
Set f = fso.GetFolder(ch)
ProgressBar1.Value = ProgressBar1.Value + CInt(f.Size / 1000000)

End Sub

Private Sub drive_OnAborted(Abort As Boolean)
Abort = False
End Sub
Private Sub drive_OnAddLogLine(TextType As NEROLib.NERO_TEXT_TYPE, Text As String)
strMessages = strMessages + Text + Chr(13) + Chr(10)
edtMessages = strMessages
End Sub
Private Sub drive_OnDoneBurn(StatusCode As NEROLib.NERO_BURN_ERROR)
strMessages = strMessages + Chr(13) + Chr(10) + nero.ErrorLog + Chr(13) + Chr(10)
strMessages = strMessages + nero.LastError + Chr(13) + Chr(10)
strMessages = strMessages + "Burn finished "
If StatusCode <> NEROLib.NERO_BURN_OK Then
strMessages = strMessages + “NOT (” & StatusCode & “)”
End If
strMessages = strMessages + “successfully!” + Chr(13) + Chr(10)
edtMessages = strMessages
btnAbort.Enabled = False
Burn.Enabled = True
ProgressBar.Value = 0
End Sub

Private Sub drive_OnDoneCDInfo(ByVal pCDInfo As NEROLib.INeroCDInfo)
On Local Error GoTo NoTracks

If pCDInfo Is Nothing Then
MsgBox “No Disk Inserted, Please Insert Disk Then Try Again!”
NumExistingTracks = -1
DriveFinished = True
Exit Sub
End If
NumExistingTracks = pCDInfo.Tracks.Count
DriveFinished = True
Exit Sub

NoTracks:
NumExistingTracks = 0
DriveFinished = True

End Sub

Private Sub drive_OnDoneImport2(ByVal bOk As Boolean, ByVal pFolder As NEROLib.INeroFolder, ByVal pCDStamp As NEROLib.INeroCDStamp, ByVal pImportInfo As NEROLib.INeroImportDataTrackInfo, ByVal importResult As NEROLib.NERO_IMPORT_DATA_TRACK_RESULT)
Dim I As Integer

If bOk Then
Set Folder = pFolder
Else
MsgBox “Error Reading In Data”
End If
DriveFinished = True

End Sub

Private Sub drive_OnDoneWaitForMedia(Success As Boolean)
strMessages = strMessages + “Done waiting for media.” + Chr(13) + Chr(10)
edtMessages = strMessages
End Sub
Private Sub drive_OnProgress(ProgressInPercent As Long, Abort As Boolean)
Abort = False
ProgressBar.Value = ProgressInPercent
End Sub
Private Sub drive_OnSetPhase(Text As String)
strMessages = strMessages + Text + Chr(13) + Chr(10)
edtMessages = strMessages
End Sub

Private Sub Drive1_Change()
Dir1.Path = Drive1.drive
Dir1.Refresh
End Sub

Private Sub chargecombo()
Combo1.Clear
Combo1.AddItem “4 X”
Combo1.AddItem “12 X”
Combo1.AddItem “16 X”
Combo1.AddItem “32 X”
Combo1.AddItem “40 X”
Combo1.AddItem “48 X”
Combo1.AddItem “52 X”
Combo1.ListIndex = 0
End Sub
Private Sub Form_Initialize()
Form1.Left = (Screen.Width - Width) / 2
Form1.Top = (Screen.Height - Height) / 2
Dir1.Path = Drive1.drive
Dir1.Refresh
chargecombo
Set nero = New nero

ProgressBar.Value = 0
ProgressBar1.Value = 0
strMessages = ""

Dim drives As INeroDrives
Set drives = nero.GetDrives(NERO_MEDIA_CDR)

For myIndex = 0 To drives.Count - 1
    AvailableDevices.AddItem drives(myIndex).DeviceName, myIndex
Next
AvailableDevices.ListIndex = 0

ErrHandler:
Exit Sub
End Sub

Private Sub nero_OnFileSelImage(FileName As String)
ImageFileDialog.CancelError = True
On Error GoTo ErrHandler
ImageFileDialog.Flags = cdlOFNHideReadOnly
ImageFileDialog.FilterIndex = 2
ImageFileDialog.ShowOpen
FileName = ImageFileDialog.FileName
Exit Sub
ErrHandler:
Exit Sub
End Sub
Private Sub nero_OnMegaFatal()
strMessages = strMessages + “A mega fatal error has occurred.” + Chr(13) + Chr(10)
edtMessages = strMessages
End Sub
Private Sub nero_OnNonEmptyCDRW(Response As NEROLib.NERO_RESPONSE)
strMessages = strMessages + “CD-RW not empty!” + Chr(13) + Chr(10)
edtMessages = strMessages
Response = NERO_RETURN_EXIT
End Sub
Private Sub nero_OnRestart()
strMessages = strMessages + “The system is being restarted.” + Chr(13) + Chr(10)
edtMessages = strMessages
End Sub
Private Sub nero_OnWaitCD(WaitCD As NEROLib.NERO_WAITCD_TYPE, WaitCDLocalizedText As String)
strMessages = strMessages + WaitCDLocalizedText + Chr(13) + Chr(10)
edtMessages = strMessages
End Sub
Private Sub nero_OnWaitCDDone()
strMessages = strMessages + “Done waiting for CD.” + Chr(13) + Chr(10)
edtMessages = strMessages
End Sub
Private Sub nero_OnWaitCDMediaInfo(LastDetectedMedia As NEROLib.NERO_MEDIA_TYPE, LastDetectedMediaName As String, RequestedMedia As NEROLib.NERO_MEDIA_TYPE, RequestedMediaName As String)
strMessages = strMessages + “Waiting for a particular media type:” + Chr(13) + Chr(10)
strMessages = strMessages + RequestedMediaName + Chr(13) + Chr(10)
edtMessages = strMessages
End Sub
Private Sub nero_OnWaitCDReminder()
strMessages = strMessages + “Still waiting for CD…” + Chr(13) + Chr(10)
edtMessages = strMessages
End Sub

Can you help me please to resolve my problem.
Thinks a lot.