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

Private m_aMRUFiles(0 To 3) As String

Public Sub Add(ByVal sFilename As String)
    Dim I, J As Integer
    Dim aNewList(0 To 3) As String
    
    J = 1
    For I = 0 To 3
        If m_aMRUFiles(I) <> sFilename Then
            aNewList(J) = m_aMRUFiles(I)
            J = J + 1
            If J = 4 Then
                Exit For
            End If
        End If
    Next
    
    aNewList(0) = sFilename
    
    For I = 0 To 3
        m_aMRUFiles(I) = aNewList(I)
    Next
End Sub

Public Property Get Item(Index As Integer) As String
Attribute Item.VB_UserMemId = 0
    Item = m_aMRUFiles(Index)
End Property

Public Sub ReadFromRegistry(oRegistryKey As RegistryKey)
    Dim I, J As Integer
    Dim nRes As Long
    
    For I = 0 To 3
        If Not oRegistryKey.GetKeyValue("MRUFile" & I, REG_SZ, m_aMRUFiles(I)) Then
            m_aMRUFiles(I) = ""
        End If
    Next
End Sub

Public Sub WriteToRegistry(oRegistryKey As RegistryKey)
    Dim I As Integer
    Dim nRes As Long
    
    For I = 0 To 3
        If m_aMRUFiles(I) <> "" Then
            oRegistryKey.SetKeyValue "MRUFile" & I, REG_SZ, m_aMRUFiles(I)
        Else
            oRegistryKey.DeleteKeyValue "MRUFile" & I
        End If
    Next
End Sub


