How the heck do I use this ?
I know I have to give it a file location and name but How does it return ? An Example would be beautiful !Code:Public Function INIGetAllSettings(SFilename As String, ByVal sSection As String) As Variant
' Returns an variant array of all keys(0) and values(1) same as GetAllSettings
' This is the complicated one. It reads all of the Key Names into a temporary array
' then after the array has been read it will crate another array. The new array is
' 2 dimensional, the first dimension is the pair number. The second dimension
' is 0 for the keyname, 1 for the value.
#If Win32 Then
Dim xRet As Long
#Else
Dim xRet As Integer
#End If
Dim sReturnStr As String
Dim nStringLen As Integer
Dim nEndOfKey As Integer
Dim nNumKeys As Integer
Dim arrValues() As Variant
nStringLen = 5000 ' Must be big enough to hold all keys
sReturnStr = String(nStringLen, Chr$(0))
nNumKeys = -1
xRet = GetPrivateProfileString(sSection, 0&, "", sReturnStr, nStringLen, SFilename)
' Parse the string, and add the elements to the array
Do While (InStr(sReturnStr, Chr$(0)) > 1)
' Get each key in the section
nEndOfKey = InStr(sReturnStr, Chr$(0))
nNumKeys = nNumKeys + 1
ReDim Preserve arrValues(nNumKeys)
arrValues(nNumKeys) = Left$(sReturnStr, nEndOfKey - 1)
sReturnStr = Mid(sReturnStr, nEndOfKey + 1)
Loop
Debug.Print INIGetAllSettings
If nNumKeys = -1 Then
' if no keys return an empty variant
INIGetAllSettings = Empty
Else
' Get the values for each key and return that, to maintain compliance with
' GetAllSettings
ReDim arrFullArray(0 To nNumKeys, 0 To 1) As Variant
For nNumKeys = LBound(arrValues) To UBound(arrValues)
arrFullArray(nNumKeys, 0) = arrValues(nNumKeys)
arrFullArray(nNumKeys, 1) = INIGetSetting(SFilename, sSection, arrValues(nNumKeys))
Next nNumKeys
INIGetAllSettings = arrFullArray
End If
End Function
