Function Reference


IniReadSectionNames

Reads all sections in a standard format .ini file.

IniReadSectionNames ( "filename" )

Parameters

filename The filename of the .ini file.

Return Value

Success: an array of all section names in the INI file.
Failure: sets the @error flag to non-zero

Remarks

A standard ini file looks like:
[SectionName]
Key=Value


The number of elements returned will be in $aArray[0]. If an @error occurs, no array is returned.

Related

IniDelete, IniRead, IniReadSection, IniRenameSection, IniWrite, IniWriteSection

Example

#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 sections labelled 'General', 'Version' and 'Other'.
IniWriteSection ($sFilePath,"General",$sSection)
IniWriteSection ($sFilePath,"Version",$sSection)
IniWriteSection ($sFilePath,"Other",$sSection)
; Read the INI section names. This will return a 1 dimensional array.
Local $aArray= IniReadSectionNames ($sFilePath)
; Check if an error occurred.
If Not @error Then
; Enumerate through the array displaying the section names.
For $i= 1To $aArray[0]
MsgBox ($MB_SYSTEMMODAL,"","Section: "&$aArray[$i])
Next
EndIf
; Delete the INI file.
FileDelete ($sFilePath)
EndFunc ;==>Example

AltStyle によって変換されたページ (->オリジナル) /