vbAccelerator - Contents of code file: cDiscRecorders.cls

This file is part of the download VB5 IMAPI Library Source, which is described in the article Image Mastering API (IMAPI) Library for VB.

VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "cDiscRecorders"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (lpvDest As
 Any, lpvSource As Any, ByVal cbCopy As Long)

Private m_cDiscMaster As IVBDiscMaster
Private m_colRecorders As Collection

Friend Sub fInit(cDiscMaster As IVBDiscMaster)
   
   Set m_cDiscMaster = cDiscMaster
   
   fRefresh
   
End Sub

Friend Sub fRefresh()
   
   ClearUpRecorders
   
   Set m_colRecorders = New Collection
   
   Dim recorderEnum As IVBEnumDiscRecorders
   m_cDiscMaster.EnumDiscRecorders recorderEnum
   recorderEnum.AddRef
   
   Dim Recorder As IVBDiscRecorder
   Dim cRecorder As cDiscRecorder
   Dim fetched As Long
   Dim hR As Long
   Do
      hR = recorderEnum.Next(1, Recorder, fetched)
      If Not FAILED(hR) And (fetched > 0) Then
         Recorder.AddRef
         Set cRecorder = New cDiscRecorder
         cRecorder.fInit m_cDiscMaster, Recorder
         Recorder.Release
         CopyMemory Recorder, 0&, 4
         
         m_colRecorders.Add cRecorder
         
      End If
   Loop While (fetched > 0) And Not FAILED(hR)
   recorderEnum.Release
   CopyMemory recorderEnum, 0&, 4
   
End Sub

Public Property Get Count() As Long
Attribute Count.VB_Description = "Gets the number of recorders attached to the
 system."
   Count = m_colRecorders.Count
End Property

Public Property Get Recorder(ByVal nIndex As Long) As cDiscRecorder
Attribute Recorder.VB_Description = "Gets the recorder at the specified 1-based
 index."
Attribute Recorder.VB_UserMemId = 0
   Set Recorder = m_colRecorders(nIndex)
End Property

Public Property Get ActiveRecorder() As cDiscRecorder
Attribute ActiveRecorder.VB_Description = "Gets the active recorder."
Dim cvbRecorder As IVBDiscRecorder
Dim sPath As String
Dim cRecorder As cDiscRecorder
Dim nIndex As Long
   
   m_cDiscMaster.GetActiveDiscRecorder cvbRecorder
   cvbRecorder.AddRef
   cvbRecorder.GetPath sPath
   For Each cRecorder In m_colRecorders
      nIndex = nIndex + 1
      If (sPath = cRecorder.Path) Then
         Set ActiveRecorder = Me.Recorder(nIndex)
      End If
   Next
   cvbRecorder.Release
   CopyMemory cvbRecorder, 0&, 4
   
End Property

Private Sub ClearUpRecorders()
   If Not (m_colRecorders Is Nothing) Then
      Dim cRecorder As cDiscRecorder
      Dim lErr As Long
      Do
         On Error Resume Next
         Set cRecorder = m_colRecorders(1)
         lErr = err.Number
         On Error GoTo 0
         
         If (lErr = 0) Then
            m_colRecorders.Remove 1
            cRecorder.fMarkDead
            Set cRecorder = Nothing
         End If
         
      Loop While (lErr = 0)
   End If
End Sub

Private Sub ClearUp()
   
   ClearUpRecorders
   
   If Not (m_cDiscMaster Is Nothing) Then
      Set m_cDiscMaster = Nothing
   End If
   
End Sub

Private Sub Class_Terminate()
   ClearUp
End Sub