# Function Reference

# IniRead

Reads a value from a standard format .ini file.

IniRead ( "filename", "section", "key", "default" )

## Parameters

filename | The filename of the .ini file.
section | The section name in the .ini file.
key | The key name in the .ini file.
default | The default value to return if the requested key is not found.

## Return Value

Success: | the requested key value as a string.
Failure: | the default string if requested key not found.

## Remarks

A standard ini file looks like:
[SectionName]
Key=Value
As stated, all values are returned as strings. If the value needs to be another datatype it must be forced by using the relevant function: Int(), Number(), Ptr() or HWnd().

## Related

FileReadLine, IniDelete, IniReadSection, IniReadSectionNames, 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)

        ; 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