Attribute VB_Name = "INI"
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long

Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long

Public Function LireINI(Entete As String, Variable As String) As String
    Dim Retour As String
    Fichier = App.path & "\config.ini"
    Retour = String(255, Chr(0))
    LireINI = Left$(Retour, GetPrivateProfileString(Entete, ByVal Variable, "", Retour, Len(Retour), Fichier))
End Function
Public Function EcrireINI(Entete As String, Variable As String, Valeur As String) As String
    Fichier = App.path & "\config.ini"
    WriteINI = WritePrivateProfileString(Entete, Variable, Valeur, Fichier)
End Function

Public Function SetIni() As Boolean
Dim fso As New FileSystemObject
Dim recup As String

On Error GoTo erreur

If Not fso.FileExists(App.path & "\config.ini") Then
    recup = EcrireINI("VIDEO", "Step", "1")
    recup = EcrireINI("VIDEO", "Sensibilite", "1")
    recup = EcrireINI("VIDEO", "Adaptatif", "1")
    recup = EcrireINI("SAVE", "Path", "C:\")
    recup = EcrireINI("SAVE", "Increment", "1")
    recup = EcrireINI("SAVE", "NbrPhotos", "0")
    recup = EcrireINI("SAVE", "Continue", "1")
Else
    If LireINI("VIDEO", "Step") = vbNullString Or Not IsNumeric(LireINI("VIDEO", "Step")) Then
        recup = EcrireINI("VIDEO", "Step", "1")
    End If
    
    If LireINI("VIDEO", "Sensibilite") = vbNullString Then
        recup = EcrireINI("VIDEO", "Sensibilite", "1")
    End If
    
    If LireINI("VIDEO", "Adaptatif") = vbNullString Then
        recup = EcrireINI("VIDEO", "Adaptatif", "1")
    End If
    
    If LireINI("SAVE", "Path") = vbNullString Then
        recup = EcrireINI("SAVE", "Path", "C:\")
    End If
    
    If LireINI("SAVE", "Increment") = vbNullString Then
        recup = EcrireINI("SAVE", "Increment", "1")
    End If
    
    If LireINI("SAVE", "NbrPhotos") = vbNullString Or Not IsNumeric(LireINI("SAVE", "NbrPhotos")) Then
        recup = EcrireINI("SAVE", "NbrPhotos", "0")
    End If
    
    If LireINI("SAVE", "Continue") = vbNullString Then
        recup = EcrireINI("SAVE", "Continue", "1")
    End If
    
End If

SetIni = True
Exit Function

erreur:
SetIni = False

End Function
