IniRenameSection
重命名配置文件(*.ini)的字段名.
IniRenameSection ( "filename", "section", "new section" [, flag = 0] )
参数
filename
|
目标 .ini 文件名.
|
section
|
.ini 文件中的字段名.
|
new section
|
新字段名称.
|
flag
|
[可选]
$FC_NOOVERWRITE(0) = (默认) 如果"new section"已经存在则放弃操作
$FC_OVERWRITE(1) = 覆盖 "new section". 这将删除"new section"任何现有关键字
常量定义在 FileConstants.au3
|
返回值
成功:
|
返回非 0 值.
|
失败:
|
返回 0. 设置 @error 为非 0 值, 因重命名字段已经存在而导致失败.(仅当"标志" = 0 时).
|
备注
标准 INI 文件结构如下:
[字段名]
关键字=值
函数示例
#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 = 1 To $aArray[0]
MsgBox($MB_SYSTEMMODAL, "", "Section: " & $aArray[$i])
Next
EndIf
; Delete the INI file.
FileDelete($sFilePath)
EndFunc ;==>Example
----------------------------------------
该函数可以通过命令 exect 调用
参见:
IniRead, IniDelete, IniWrite, IniReadSection, IniReadSectionNames, IniWriteSection
exect=IniRenameSection(EnvGet('COMMANDER_INI'),'WWW','XXX') ;; 重命名为[XXX]中的Wincmd.ini部分[WWW]
© Аверин Андрей для Total Commander Image Averin-And@yandex.ru
|