Private Declare Function GetPrivateProfileSection Lib "kernel32" Alias "GetPrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Function EnumIniKeys(ByVal sIniPath As String, ByVal sSection As String, ByRef asKeys() As String) As Long
Dim sBuffer As String, sKeys As String, i As Long
'
' on récupère toutes les clés+valeurs
sBuffer = VBA.Strings.String$(458752, vbNullChar)
sKeys = VBA.Strings.Left$(sBuffer, GetPrivateProfileSection(sSection, sBuffer, Len(sBuffer), sIniPath) - 1)
If (VBA.Strings.LenB(sKeys) And VBA.Strings.InStrB(1, sKeys, "=")) Then
asKeys = VBA.Strings.Split(sKeys, vbNullChar)
For i = LBound(asKeys) To UBound(asKeys)
' l'API nous retourne aussi les valeurs, on nettoie
asKeys(i) = VBA.Strings.LeftB$(asKeys(i), VBA.Strings.InStrB(1, asKeys(i), "=") - 1)
Next i
EnumIniKeys = LBound(asKeys) + UBound(asKeys) + 1
End If
End Function