Attribute VB_Name = "modMRUFiles"
Option Explicit

Public g_aMRUFiles(0 To 3) As String

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

Public Sub ReadMRUFiles(ByVal hKey As Long)
    Dim I, J As Integer
    Dim nRes As Long
    
    For I = 0 To 3
        nRes = GetKeyValue(hKey, "MRUFile" & I, g_aMRUFiles(I), True)
        If nRes <> 0 Then
            g_aMRUFiles(I) = ""
        End If
    Next
End Sub

Public Sub WriteMRUFiles(ByVal hKey As Long)
    Dim I As Integer
    Dim nRes As Long
    
    For I = 0 To 3
        If g_aMRUFiles(I) <> "" Then
            nRes = SetKeyValue(hKey, "MRUFile" & I, g_aMRUFiles(I))
        Else
            nRes = DeleteKeyValue(hKey, "MRUFile" & I, True)
        End If
    Next
End Sub

