Function Reference


IniRenameSection

Renames a section in a standard format .ini file.

IniRenameSection ( "filename", "section", "new section" [, flag = 0] )

Parameters

filename The filename of the .ini file.
section The section name in the .ini file.
new section The new section name.
flag [optional]
$FC_NOOVERWRITE(0) = (default) Fail if "new section" already exists.
$FC_OVERWRITE(1) = Overwrite "new section". This will erase any existing keys in "new section".

Constants are defined in FileConstants.au3.

Return Value

Success: Non-zero.
Failure: 0 and may sets the @error flag to non-zero, if renaming failed because the section already exists (only when flag = 0).

Remarks

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

Related

IniDelete, IniRead, IniReadSection, IniReadSectionNames, 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)
; Rename the section labelled 'General' to 'System'.
IniRenameSection ($sFilePath,"General","System")
; 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 によって変換されたページ (->オリジナル) /