TIniFile
is a thin wrapper around the PrivateProfile API.
If you do not specify a full path, the API creates the .ini file relative to the OS system folder, which you likely do not have write access to.
If you base the filename on Application.ExeName
or ParamStr(0)
, you are creating the .ini file relative to your app's folder, which you likely do not have write access to, especially if the app is installed under Program Files
.
What you should do is use SHGetFolderPath(CSIDL_APPDATA)
or similar API to get the path to tbe user's AppData folder, create your own subfolder under it, and then create your .ini file in that subfolder.