Reads all key/value pairs from a section in a standard format .ini file.
IniReadSection ( "filename", "section" )
A standard ini file looks like:
[SectionName]
Key=Value
The number of elements returned will be in $aArray[0][0]. If an @error occurs, no array is created.
$aArray[0][0] = Number
$aArray[1][0] = 1st Key
$aArray[1][1] = 1st Value
$aArray[2][0] = 2nd Key
$aArray[2][1] = 2nd Value
...
$aArray[n][0] = nth Key
$aArray[n][1] = nth Value
Only the first 32767 chars are read for legacy reasons.
IniDelete, IniRead, IniReadSectionNames, IniRenameSection, IniWrite, IniWriteSection
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
Example()
Func Example()
; Create a constant variable in Local scope of the filepath that will be read/written to.
Local Const $sFilePath= _WinAPI_GetTempFileName (@TempDir )
; Create an INI section structure as a string.
Local $sSection= "Title=AutoIt"&@LF &"Version="&@AutoItVersion &@LF &"OS="&@OSVersion
; Write the string to the section labelled 'General'.
IniWriteSection ($sFilePath,"General",$sSection)
; Read the INI section labelled 'General'. This will return a 2 dimensional array.
Local $aArray= IniReadSection ($sFilePath,"General")
; Check if an error occurred.
If Not @error Then
; Enumerate through the array displaying the keys and their respective values.
For $i= 1To $aArray[0][0]
MsgBox ($MB_SYSTEMMODAL,"","Key: "&$aArray[$i][0]&@CRLF &"Value: "&$aArray[$i][1])
Next
EndIf
; Delete the INI file.
FileDelete ($sFilePath)
EndFunc ;==>Example