vbAccelerator - Contents of code file: frmIDiscMaster.frm

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

VERSION 5.00
Object = "{CA5A8E1E-C861-4345-8FF8-EF0A27CD4236}#1.1#0"; "vbalTreeView6.ocx"
Begin VB.Form frmDiscMaster 
   Caption         =   "vbAccelerator: IMAPI CD Properties"
   ClientHeight    =   5805
   ClientLeft      =   4755
   ClientTop       =   2040
   ClientWidth     =   6630
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "frmIDiscMaster.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   5805
   ScaleWidth      =   6630
   Begin vbalTreeViewLib6.vbalTreeView tvwRecorders 
      Height          =   4755
      Left            =   120
      TabIndex        =   2
      Top             =   480
      Width           =   6375
      _ExtentX        =   11245
      _ExtentY        =   8387
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin VB.CommandButton cmdRefresh 
      Caption         =   "&Refresh"
      Height          =   375
      Left            =   180
      TabIndex        =   1
      Top             =   5340
      Width           =   1335
   End
   Begin VB.Label lblRecorderInformation 
      Caption         =   "Recorder Information:"
      Height          =   255
      Left            =   180
      TabIndex        =   0
      Top             =   120
      Width           =   6255
   End
End
Attribute VB_Name = "frmDiscMaster"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private m_cDiscMaster As cDiscMaster

Private Sub showRecorders()
Dim cRecorders As cDiscRecorders
Dim cRecorder As cDiscRecorder
Dim iRecorder As Long
Dim iProperty As Long
Dim nodRecorder As cTreeViewNode
Dim nodMedia As cTreeViewNode
Dim nodProperties As cTreeViewNode
Dim nodFormats As cTreeViewNode
Dim nodJoliet As cTreeViewNode
Dim sKey As String
Dim cMedia As cMediaInfo

   Screen.MousePointer = vbHourglass

   Set cRecorders = m_cDiscMaster.Recorders
   
   For iRecorder = 1 To cRecorders.Count
      Set cRecorder = cRecorders(iRecorder)
      With cRecorder
         
         sKey = "R:" & iRecorder
         Set nodRecorder = tvwRecorders.Nodes.Add(, , sKey, "Recorder " &
          iRecorder)
         
         nodRecorder.AddChildNode sKey & ":ID", "PNP ID=" & .PnPID
         nodRecorder.AddChildNode sKey & ":Type", "Type=" &
          RecorderTypeName(.RecorderType)
         nodRecorder.AddChildNode sKey & ":Path", "Path = " & cRecorder.Path
         nodRecorder.AddChildNode sKey & ":Vendor", "Vendor = " &
          cRecorder.VendorId
         nodRecorder.AddChildNode sKey & ":Product", "Product = " &
          cRecorder.ProductId
         nodRecorder.AddChildNode sKey & ":Revision", "Revision = " &
          cRecorder.RevisionId
         nodRecorder.AddChildNode sKey & ":State", "State=" &
          RecorderStateName(.RecorderState)
         
         Me.Refresh
         
         .OpenExclusive
         Set cMedia = cRecorder.MediaInfo
         Set nodMedia = nodRecorder.AddChildNode(, "Media")
         If cMedia.MediaPresent Then
            nodMedia.AddChildNode sKey & ":MediaType", "Media Type=" &
             MediaTypeName(cMedia.MediaType)
            nodMedia.AddChildNode sKey & ":MediaFlags", "Media Flags=" &
             MediaFlagNames(cMedia.MediaFlags)
         
            nodMedia.AddChildNode sKey & ":Sessions", "Sessions=" &
             cMedia.Sessions
            nodMedia.AddChildNode sKey & ":LastTrack", "LastTrack=" &
             cMedia.LastTrack
            nodMedia.AddChildNode sKey & ":Start", "Start=" &
             cMedia.StartAddress
            nodMedia.AddChildNode sKey & ":Next", "Next=" & cMedia.LastWritable
            nodMedia.AddChildNode sKey & ":Free", "Free=" & cMedia.FreeBlocks
         Else
            nodMedia.AddChildNode sKey & ":NoMedia", "No Media in drive"
         End If
         
         .CloseExclusive
         DoEvents
         nodMedia.Expanded = True
         
         Set nodProperties = nodRecorder.AddChildNode(sKey & ":PROPS",
          "Recorder Properties")
         With .Properties
            For iProperty = 1 To .Count
               With .Property(iProperty)
                  nodProperties.AddChildNode sKey & ":PROPS:" & iProperty,
                   .Name & " = " & .Value
               End With
            Next iProperty
         End With
         nodProperties.Expanded = True
         
         DoEvents
         Me.Refresh
         
         Set nodFormats = nodRecorder.AddChildNode(sKey & ":FORMATS", "Recorder
          Formats")
         If (.SupportsRedbook) Then
            nodFormats.AddChildNode sKey & ":REDBOOK", "Redbook (Audio)"
         End If
         If (.SupportsJoliet) Then
            Set nodJoliet = nodFormats.AddChildNode(sKey & ":JOLIET", "Joliet
             (Data)")
         End If
         nodFormats.Expanded = True
                  
         nodRecorder.Expanded = True
         
      End With
   Next iRecorder
   
   Screen.MousePointer = vbDefault
   
End Sub

Private Sub Command2_Click()
   With m_cDiscMaster.Recorders.Recorder(1)
      .OpenExclusive
      .Eject
      .CloseExclusive
   End With
End Sub

Private Sub cmdRefresh_Click()
   '
   lblRecorderInformation.Caption = "Getting recorder information, please
    wait..."
   tvwRecorders.Nodes.Clear
   Me.Enabled = False
   showRecorders
   lblRecorderInformation.Caption = "Recorder Information:"
   Me.Enabled = True
   '
End Sub

Private Sub Form_Load()

   lblRecorderInformation.Caption = "Getting recorder information, please
    wait..."

   Me.Enabled = False
   Me.Show
   Me.Refresh

   Set m_cDiscMaster = New cDiscMaster
   m_cDiscMaster.Initialise
   
   showRecorders
   
   lblRecorderInformation.Caption = "Recorder Information:"
   Me.Enabled = True

End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
   
   Me.Enabled = False
   
   lblRecorderInformation.Caption = "Shutting down, please wait..."
   tvwRecorders.Nodes.Clear
   Me.Refresh
   
   Screen.MousePointer = vbHourglass
   m_cDiscMaster.ClearUp
   Screen.MousePointer = vbDefault
   
End Sub

Private Sub Form_Resize()
   '
   On Error Resume Next
   tvwRecorders.Move tvwRecorders.Left, tvwRecorders.Top, Me.ScaleWidth -
    tvwRecorders.Left * 2, _
      Me.ScaleHeight - tvwRecorders.Top - tvwRecorders.Left * 2 -
       cmdRefresh.Height
   cmdRefresh.Top = tvwRecorders.Top + tvwRecorders.Height + tvwRecorders.Left
   '
End Sub