I normally write my Delphi applications with an INI file saved in the application's own folder:
ConfigFile:= ChangeFileExt(ParamStr(0), '.ini');
IniFile:= TIniFile.Create(ConfigFile);
try
with IniFile do
begin
// etc
However, one particular application I'm writing, I want to use a setup wizard (Inno) and also give users the opportunity to install the app in Program Files (x86)\MyProg.
What is new to me is that Windows doesn't save the INI file in the install directory but "somewhere else".
Uninstalling the app through Control Panel successfully removes all the items from the Program Files (x86) folder (including the folder) but - in common with a lot of programs - if it is re-installed, all the configuration settings are restored. So they must be stored somewhere that Control Panel | Uninstall doesn't remove.
So my question is where?
Thanks, John.
Writing files underneath the Program Files
folders is forbidden by non-admin users. If an app running as a non-admin user tries to write a file there, and the app does not have an UAC manifest, then Windows protects the Program Files
folder and silently redirects all access to a VirtualStore folder within the user's profile.
Common file and registry virtualization issues in Windows Vista or in Windows 7
Windows 7 Application Compatibility Issues …Demystified !!!
In this case, when you write your INI to this file:
C:\Program Files (x86)\MyProg\MyProg.ini
It is actually written to this file instead:
%USERPROFILE%\AppData\Local\VirtualStore\Program Files (x86)\MyProg\MyProg.ini
You should change your app to store the INI file in a more appropriate location, such as:
%LOCALAPPDATA%\MyProg\MyProg.ini
Or:
%PROGRAMDATA%\MyProg\MyProg.ini
Where Should I Store my Data and Configuration Files if I Target Multiple OS Versions?