Why won't you use quotes, as Leefme suggested?
Code: Select all
#NoEnv
IniValue := " Three leading and trailing spaces! "
IniFile := A_ScriptDir . "\Test.ini"
FileDelete, %IniFile%
; without quotes
IniWrite, %IniValue%, %IniFile%, Main, IniValue
IniRead, Value, %IniFile%, Main, IniValue
MsgBox, 0, Without Quotes, % "|" . Value . "|`n|" . IniValue . "|"
; using quotes
IniWrite, '%IniValue%', %IniFile%, Main, IniValue
IniRead, Value, %IniFile%, Main, IniValue
MsgBox, 0, Quotes, % "|" . Value . "|`n|" . IniValue . "|"
; using double-quotes
IniWrite, "%IniValue%", %IniFile%, Main, IniValue
IniRead, Value, %IniFile%, Main, IniValue
MsgBox, 0, Double-Quotes, % "|" . Value . "|`n|" . IniValue . "|"
FileDelete, %IniFile%
ExitApp
GetPrivateProfileString() ->
Remarks:
If the string associated with lpKeyName is enclosed in single or double quotation marks, the marks are discarded when the GetPrivateProfileString function retrieves the string.