Returning OnDoneCDInfo

vbimport

#1

I am trying to query the title property from a disk in my burner. I execute the drive.CDInfo(NERO_CDINFO_FLAGS.NERO_READ_CD_TEXT) method and the drive spins up, but I never seem to get the event to fire.

Can someone provide a couple pointers on doing this in VB 2005?

thanks

Some code…

Public WithEvents drive As NEROLib.NeroDrive
Public WithEvents nero As NEROLib.Nero
Public drives As NEROLib.INeroDrives

Private Sub drive_OnDoneCDInfo(ByVal pCDInfo As NEROLib.INeroCDInfo)
    If pCDInfo Is Nothing Then
        Exit Sub
    End If
    MessageBox.Show(pCDInfo.Title.ToString)
    'set done flag
    bDone = True
End Sub


Private Sub btnRun_Click()

    Dim myIndex As Object
    Dim drives As NEROLib.INeroDrives
    nero = New NEROLib.Nero

    drives = nero.GetDrives(NERO_MEDIA_TYPE.NERO_MEDIA_DVD_ANY)
    For myIndex = 0 To drives.Count - 1
        bDone = False
        drive = drives.Item(myIndex)
        drive.CDInfo(NERO_CDINFO_FLAGS.NERO_READ_CD_TEXT) 

        While bDone <> True
            Application.DoEvents()
        End While
    Next
End Sub

#2

OK, it was too late in the night and I missed this little tidbit. I had actually spent quite a bit of time trying to figure the problem out :doh: . It turns out that a good nights sleep does wonders.

The drive_OnDoneCDInfo procedure was mostly fine. What was missing was the little extra bit at the top which associates the procedure with the event.

Not working:

Private Sub drive_OnDoneCDInfo(ByVal pCDInfo As NEROLib.INeroCDInfo)

Working:

Private Sub drive_OnDoneCDInfo(ByVal pCDInfo As NEROLib.INeroCDInfo) [B]Handles drive.OnDoneCDInfo[/B]