IniDelete
删除配置文件(*.ini)的值.
IniDelete ( "filename", "section" [, "key"] )
参数
filename
|
目标 .ini 文件名.
|
section
|
.ini 文件中的字段名.
|
key
|
[可选] 要删除 .ini 文件的关键字名称.
若不指定关键字, 则删除整个字段.
使用参数值 Default 同样能用于删除字段.
|
返回值
成功:
|
返回 1.
|
失败:
|
返回 0, INI文件不存在或如果该文件为只读.
|
备注
标准 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)
; Write the value of 'AutoIt' to the key 'Title' and in the section labelled 'General'.
IniWrite($sFilePath, "General", "Title", "AutoIt")
; Read the INI file for the value of 'Title' in the section labelled 'General'.
Local $sRead = IniRead($sFilePath, "General", "Title", "Default Value")
; Display the value returned by IniRead.
MsgBox($MB_SYSTEMMODAL, "", "The value of 'Title' in the section labelled 'General' is: " & $sRead)
; Delete the key labelled 'Title'.
IniDelete($sFilePath, "General", "Title")
; Read the INI file for the value of 'Title' in the section labelled 'General'.
$sRead = IniRead($sFilePath, "General", "Title", "Default Value")
; Display the value returned by IniRead. Since there is no key stored the value will be the 'Default Value' passed to IniRead.
MsgBox($MB_SYSTEMMODAL, "", "The value of 'Title' in the section labelled 'General' is: " & $sRead)
; Delete the INI file.
FileDelete($sFilePath)
EndFunc ;==>Example
----------------------------------------
该函数可以通过命令 exect 调用
参见:
IniRead, IniWrite, IniReadSection, IniReadSectionNames, IniRenameSection, IniWriteSection
exect=IniDelete(EnvGet('COMMANDER_INI'),'WWW','Key') ;; 从键值键的[WWW]部分删除Wincmd.ini文件
exect=IniDelete(EnvGet('COMMANDER_INI'),'WWW') ;; 从Wincmd.ini文件部分删除[WWW]
© Аверин Андрей для Total Commander Image Averin-And@yandex.ru
|