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

📄 form1.vb

📁 gbg gdhsg dgshds ds dsgdhsg dhs d sd s ds dhsgdhs d sjd sd sgdash dhasdhashd as
💻 VB
字号:
Imports NEROLib
Imports System.IO

Public Class Form1
    Private WithEvents nero As New nero
    Private WithEvents drive As NeroDrive

    Private result As Boolean

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim i As Integer
        Dim drives As INeroDrives
        ProgressBar.Value = 0
        btnAbort.Enabled = False
        btnStart.Enabled = True

        drives = nero.GetDrives(NERO_MEDIA_TYPE.NERO_MEDIA_CDR Or NERO_MEDIA_TYPE.NERO_MEDIA_CDRW)

        For i = 0 To drives.Count - 1
            If drives.Item(i).DevType = NERO_SCSI_DEVTYPE.NERO_SCSI_DEVTYPE_WORM And drives.Item(i).DeviceName <> "Image Recorder" Then
                drive = drives.Item(i)
            End If
        Next
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If FolderBrowserDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            txtDir.Text = FolderBrowserDialog1.SelectedPath
        End If
    End Sub
    Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
        Dim isotrack As New NeroISOTrack
        'Dim file As NeroFile
        Dim rootFolder As New NeroFolder
        Try
            btnAbort.Enabled = True
            btnStart.Enabled = False

            isotrack.Name = "TestDisc"
            isotrack.BurnOptions = NERO_BURN_OPTIONS.NERO_BURN_OPTION_CREATE_ISO_FS Or NERO_BURN_OPTIONS.NERO_BURN_OPTION_USE_JOLIET
            isotrack.RootFolder = rootFolder

            'For Each f As String In My.Computer.FileSystem.GetFiles(txtDir.Text, FileIO.SearchOption.SearchAllSubDirectories, "*")
            '    Dim fi As New FileInfo(f)
            '    file = New NeroFile
            '    file.Name = fi.Name
            '    file.SourceFilePath = fi.FullName
            '    rootFolder.Files.Add(file)
            'Next
            BuildFileFolderTree(rootFolder, My.Computer.FileSystem.GetDirectoryInfo(txtDir.Text))

 
            drive.BurnIsoAudioCD("", "Orders", 0, isotrack, Nothing, Nothing, NERO_BURN_FLAGS.NERO_BURN_FLAG_DETECT_NON_EMPTY_CDRW Or NERO_BURN_FLAGS.NERO_BURN_FLAG_WRITE, 0, NERO_MEDIA_TYPE.NERO_MEDIA_CD)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub

    Private Sub nero_OnNonEmptyCDRW(ByRef Response As NEROLib.NERO_RESPONSE) Handles nero.OnNonEmptyCDRW
        MessageBox.Show("CD-RW not empty!" + Chr(13) + Chr(10))
        Response = NERO_RESPONSE.NERO_RETURN_EXIT
    End Sub
    Private Sub nero_OnWaitCDMediaInfo(ByRef LastDetectedMedia As NEROLib.NERO_MEDIA_TYPE, ByRef LastDetectedMediaName As String, ByRef RequestedMedia As NEROLib.NERO_MEDIA_TYPE, ByRef RequestedMediaName As String) Handles nero.OnWaitCDMediaInfo
        MessageBox.Show("WaitCDMediaInfo: " & LastDetectedMediaName & " detected. " & RequestedMediaName & " required.")
    End Sub
    Private Sub drive_OnDoneBurn(ByRef StatusCode As NEROLib.NERO_BURN_ERROR) Handles drive.OnDoneBurn
        If StatusCode <> NERO_BURN_ERROR.NERO_BURN_OK Then
            MsgBox("Burn Failed")
        Else
            MsgBox("Burn Finished OK!" + Chr(13) + Chr(10))
            result = True
        End If

        btnAbort.Enabled = False
        btnStart.Enabled = True
        ProgressBar.Value = 0

    End Sub
    Private Sub drive_OnProgress(ByRef ProgressInPercent As Integer, ByRef Abort As Boolean) Handles drive.OnProgress
        Abort = False
        ProgressBar.Value = ProgressInPercent
    End Sub
    Private Sub drive_OnAborted(ByRef Abort As Boolean) Handles drive.OnAborted
        Abort = False
    End Sub
    Private Sub drive_OnDriveStatusChanged(ByVal driveStatus As NEROLib.NERO_DRIVESTATUS_RESULT) Handles drive.OnDriveStatusChanged
        StatusStrip1.Text = "DriveStatusChanged: " & driveStatus.ToString
    End Sub
    Private Sub btnAbort_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAbort.Click
        nero.Abort()
    End Sub

    Private Function BuildFileFolderTree(ByRef neroRootFolder As NEROLib.NeroFolder, ByVal startDir As DirectoryInfo) As Long
        Dim cummulativeSize As Long = 0
        Dim files As FileInfo() = startDir.GetFiles
        For Each file As FileInfo In files
            ToolStripStatusLabel1.Text = "Adding file: " + file.FullName
            Dim neroFile As NEROLib.NeroFile = New NEROLib.NeroFile
            neroFile.Name = file.Name
            neroFile.SourceFilePath = file.FullName
            neroRootFolder.Files.Add(neroFile)
            cummulativeSize += file.Length
        Next
        Dim directories As DirectoryInfo() = startDir.GetDirectories
        For Each directory As DirectoryInfo In directories
            ToolStripStatusLabel1.Text = "Adding directory: " + directory.FullName
            Dim neroFolder As NEROLib.NeroFolder = New NEROLib.NeroFolder
            neroFolder.Name = directory.Name
            neroRootFolder.Folders.Add(neroFolder)
            cummulativeSize += BuildFileFolderTree(neroFolder, directory)
        Next
        Return cummulativeSize
    End Function
End Class




⌨️ 快捷键说明

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