Deletes a value from a standard format .ini file.
IniDelete ( "filename", "section" [, "key"] )
filename | The filename of the .ini file. |
section | The section name in the .ini file. |
key | [optional] The key name in the .ini file to delete. If the key name is not given the entire section is deleted. The Default keyword may also be used which will cause the section to be deleted. |
Success: | 1. |
Failure: | 0 if the INI file does not exist or if the file is read-only. |
A standard ini file looks like:
[SectionName]
Key=Value
IniRead, IniReadSection, 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)
; 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