Copy a Folder to CD using VB 6

Hi,

I am working on vb6, and unable to write code related to copying a folder to cd. :confused:

I am using nerocom.dll.

I refered
http://www.google.com/url?sa=U&start=18
&q=http://club.cdfreaks.com/lite/t-82050.html&e=7207
, but i am still unable to compile the code.

Option Explicit

Public WithEvents Nero As Nero

Public WithEvents Drive As NeroDrive

Dim Drives As INeroDrives
Dim Folder As INeroFolder
Dim Isotrack As NeroISOTrack
Dim File As NeroFile

Private Sub cmd_Abort_Click()
Nero.Abort
End Sub


'Recursive function to build the Folders/Files to burn
Private Sub BuildFileFolderTree(ByRef nroFolderToUse As NeroFolder,
folCurrent As Folder[B] )
Dim folTMP As Folder
Dim filTMP As File
Dim nroFolTmp As NeroFolder
Dim nroFilTmp As NeroFile

'Add all files in the current directory
For Each filTMP In folCurrent.Files
Set nroFilTmp = New NeroFile
nroFilTmp.Name = filTMP.Name
nroFilTmp.SourceFilePath = filTMP.Path
nroFolderToUse.Files.Add nroFilTmp
Next

'Write the sub folders
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
[/B]

Private Sub cmd_Burn_Click()
Dim Source_Dir As String
Dim X As Boolean
Dim temp
Dim FSO As New FileSystemObject

Source_Dir = “C:\unison\bend”
lst_Messages.Clear

cmd_Abort.Enabled = True
cmd_Burn.Enabled = False

Set Folder = New NeroFolder
Set Drives = Nero.GetDrives(NERO_MEDIA_CDR)
Set Drive = Drives(lst_AvailableDevices.ListIndex)
Set Isotrack = New NeroISOTrack

Call BuildFileFolderTree(Folder, FSO.GetFolder(Source_Dir))

Isotrack.Name = “Unison”
Isotrack.RootFolder = Folder
Isotrack.BurnOptions = NERO_BURN_OPTION_CREATE_ISO_FS + NERO_BURN_OPTION_USE_JOLIET
If Drive.Capabilities And NERO_CAP_BUF_UNDERRUN_PROT Then
Drive.BurnIsoAudioCD “Unison”, “Backup”, 0, Isotrack, Nothing, Nothing, NERO_BURN_FLAG_WRITE + NERO_BURN_FLAG_BUF_UNDERRUN_PROT, 0,
NERO_MEDIA_CD
Else
Drive.BurnIsoAudioCD “Unison”, “Backup”, 0, Isotrack, Nothing, Nothing, NERO_BURN_FLAG_WRITE, 0, NERO_MEDIA_CD
End If

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)
If Not SplitText(Text) Then
MsgBox “Error Splitting Message Data!”
End If
End Sub

Private Function SplitText(ByVal Data As String) As Boolean
Dim temp As String
Dim I As Integer

SplitText = False

temp = “”
For I = 1 To Len(Data)
If Mid$(Data, I, 1) = Chr$(13) Then
lst_Messages.AddItem Trim$(temp)
temp = “”
ElseIf Mid$(Data, I, 1) <> Chr$(10) Then
temp = temp + Mid$(Data, I, 1)
End If
Next
If temp <> “” Then
lst_Messages.AddItem Trim$(temp)
End If
If lst_Messages.ListCount <> 0 Then
lst_Messages.ListIndex = lst_Messages.ListCount - 1
lst_Messages.Refresh
End If
SplitText = True

End Function

Private Sub drive_OnDoneBurn(StatusCode As NEROLib.NERO_BURN_ERROR)
Dim strMessages As String

If Not SplitText(Nero.ErrorLog) Then
MsgBox “Error Splitting Message Data!”
End If
If Not SplitText(Nero.LastError) Then
MsgBox “Error Splitting Message Data!”
End If

strMessages = "Burn finished "
If StatusCode <> NEROLib.NERO_BURN_OK Then
strMessages = strMessages + “NOT Successfully (” & StatusCode & “)”
Else
strMessages = strMessages + “Successfully”
End If

lst_Messages.AddItem strMessages
If lst_Messages.ListCount <> 0 Then
lst_Messages.ListIndex = lst_Messages.ListCount - 1
lst_Messages.Refresh
End If
cmd_Abort.Enabled = False

cmd_Burn.Enabled = True
pgs_progress1.Value = 0

End Sub

Private Sub drive_OnDoneWaitForMedia(Success As Boolean)
lst_Messages.AddItem “Done waiting for media.”
If lst_Messages.ListCount <> 0 Then
lst_Messages.ListIndex = lst_Messages.ListCount - 1
lst_Messages.Refresh
End If
End Sub

Private Sub drive_OnProgress(ProgressInPercent As Long, Abort As Boolean)
Abort = False
pgs_progress1.Value = ProgressInPercent
End Sub

Private Sub drive_OnSetPhase(Text As String)
If Not SplitText(Text) Then
MsgBox “Error Splitting Message Data!”
End If
End Sub

Private Sub Form_Initialize()
Dim myIndex As Integer
Set Nero = New Nero

pgs_progress1.Value = 0
lst_Messages.Clear

Set Drives = Nero.GetDrives(NERO_MEDIA_CDR)

For myIndex = 0 To Drives.Count - 1
lst_AvailableDevices.AddItem Drives(myIndex).DeviceName, myIndex
Next
'set to second item (normally would use first or allow to select?)
lst_AvailableDevices.ListIndex = 1
ErrHandler:
Exit Sub
End Sub

Private Sub nero_OnMegaFatal()
lst_Messages.AddItem “A mega fatal error has occurred.”
If lst_Messages.ListCount <> 0 Then
lst_Messages.ListIndex = lst_Messages.ListCount - 1
lst_Messages.Refresh
End If
End Sub

Private Sub nero_OnNonEmptyCDRW(Response As NEROLib.NERO_RESPONSE)
lst_Messages.AddItem “CD-RW not empty!”
If lst_Messages.ListCount <> 0 Then
lst_Messages.ListIndex = lst_Messages.ListCount - 1
lst_Messages.Refresh
End If
Response = NERO_RETURN_EXIT
End Sub

Private Sub nero_OnRestart()
lst_Messages.AddItem “The system is being restarted.”
If lst_Messages.ListCount <> 0 Then
lst_Messages.ListIndex = lst_Messages.ListCount - 1
lst_Messages.Refresh
End If
End Sub

Private Sub nero_OnWaitCD(WaitCD As NEROLib.NERO_WAITCD_TYPE, WaitCDLocalizedText As String)
If Not SplitText(WaitCDLocalizedText) Then
MsgBox “Error Splitting Message Data!”
End If
End Sub

Private Sub nero_OnWaitCDDone()
lst_Messages.AddItem “Done waiting for CD.”
If lst_Messages.ListCount <> 0 Then
lst_Messages.ListIndex = lst_Messages.ListCount - 1
lst_Messages.Refresh
End If
End Sub

Private Sub nero_OnWaitCDMediaInfo(LastDetectedMedia As NEROLib.NERO_MEDIA_TYPE, LastDetectedMediaName As String, RequestedMedia As
NEROLib.NERO_MEDIA_TYPE, RequestedMediaName As String)
lst_Messages.AddItem “Waiting for a particular media type:”
If Not SplitText(RequestedMediaName) Then
MsgBox “Error Splitting Message Data!”
End If
End Sub

Private Sub nero_OnWaitCDReminder()
lst_Messages.AddItem “Still waiting for CD…”
If lst_Messages.ListCount <> 0 Then
lst_Messages.ListIndex = lst_Messages.ListCount - 1
lst_Messages.Refresh
End If
End Sub

I got a problem in “BuildFileFolderTree” procedure, on second parameter “folCurrent As Folder” is notSays Compile Error: User
type not defined

please help… Its very important.

Regards,Waseem…

I am not sure about this as it is user’s code, but I would say you need to include “Scripting” library in your References.

yes, i have done both…

  • Registerd
  • aded the reference…

I am sure about that i am getting the methods and properties from the nerocom.dll.

if any1 have the solution, plz share with me… i want to copy folder to CD using vb6.

thnx in advance.

alexp thnx,

its now compiling after adding “Microsoft Scripting Runtime”.

BUT STILL NOT Working, giving runtime error on “BurnIsoAudioCD” procedure.

can anyone help.

So, you fixed the compile error… What is the runtime error exactly?

yes elexp,

But runtime error occur.

Its on the “BurnIsoAudioCD” method. :confused:

I am not a VB expert but run-time errors tend to have an error code and/or a description, don’t they? A run-time error “on the “BurnIsoAudioCD” method” doesn’t tell us much. You first had compile-time problems and you fixed them. Now you get an error while the application is running but we need to know the nature of the error in order to be able to give you any pointers.

I just tried the above code and got it to run ok.
What nero version are you using?

Also this was my initial attempt at getting a working solution, try the code at:

http://club.cdfreaks.com/showthread.php?t=84858&page=2&pp=25

and/or

http://club.cdfreaks.com/showthread.php?t=116409

Mike

THIS ERROR OCUR, NOW…

APPLICATION ERROR:
The instruction at “0x04571a24” referenced memory at “0x00000010”. The memory could not be “written”.

Click on OK to terminate the program
Click on CANCEL to debug the program

unison, i m using dlls from Nero5 Burning Rom, V5.5

WaseeM.


System have:
Windows 2000
Service Pack 4 on P3


-References:
Nero API 1.3 Type Library
MS Scripting Runtime

-components:
Microsoft Windows Common Dialog 6.0 (SP4)

any idea who can i run my app.

WaseeM.

I suggest you upgrade to at least version 6.3.1.6, this was the earliest version on which the code would work.

Mike

I am not even sure how you got access to NeroCOM if you only got Nero 5.5 installed. NeroCOM is only to be used with Nero 6 and better and is therefore distributed with Nero 6+. The problems you see are most definitely related to this. Please upgrade to the newest Nero release or at least to a recent version.

If you take a minute to look at NeroSDK 1.05/NeroCOM docs, you will find on bottom of page 6 that you need at least Nero 6.

thnx, alexp. I have got NeroSDK 1.05 and docs says minimum requirement is nero6.

I will try nero6 within 20 min and i’ll reply then.

I must say u guys are really helping me… tnx again.

WaseeM.

Hello!

Guys i done it successfully.

Thanks Alot.

WaseeM.

Hi,

I have done it successfully.

After getting 6.3, it was just matter of minutes.

tnx alexp, and unison.

hi,
i want copy my Access Data Base to CD. i try this code & it copies the all the contents of folder. but when i try to open my DataBase. Error is " Unrecognized Database formate ".

Regard
Sonal.

hi,
i want copy my Access Data Base to CD. i try this code & it copies the all the contents of folder. but when i try to open my DataBase. Error is " Unrecognized Database formate ".

Regard
Sonal.

Are you trying to open the database directly from the CD? Not sure if this would give the error - but Access will be trying to create a .ldb which it will not be able to do on a read-only CD.

Mike

NO Mike, i try both by open from CD & by coping the DataBase return to Hard-disk from the CD i write using the Code. but the error is same " Unrecognized formate " . it also change the formate of MS- Word document Which i include in the folder. I Think its because of we use Drive.BurnIsoAudioCD. plz help.
ThnX

 SONAL

hi mike,
fiel type Result On CD
text file is empty
image file no prive & not opening in any image editor.
.mp3 not playing
.exe not a valid Win32 Apllication.

this all happend On CD and after coping then back to Hard disk.

i have install
Windows ME
Nero 6
plz help

           ThnX

Regard
SONAL