Windows在哪里将其替代文件存储在INI文件(Delphi 7)中 [英] Where does Windows store its alternative to the INI file (Delphi 7)

查看:55
本文介绍了Windows在哪里将其替代文件存储在INI文件(Delphi 7)中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常使用保存在应用程序自己文件夹中的INI文件编写我的Delphi应用程序:

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

但是,我正在编写一个特定的应用程序,我想使用安装向导(Inno),并且还为用户提供了将程序安装在Program Files(x86)\ MyProg中的机会.

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.

对我而言,新功能是Windows不会将INI文件保存在安装目录中,而是保存在其他地方".

What is new to me is that Windows doesn't save the INI file in the install directory but "somewhere else".

通过控制面板卸载该应用程序成功地从Program Files(x86)文件夹(包括该文件夹)中删除了所有项目,但是-与许多程序一样-如果重新安装该应用程序,则将还原所有配置设置.因此,它们必须存储在控制面板" |控制面板"中.卸载不会删除.

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.

所以我的问题在哪里?

谢谢,约翰.

推荐答案

非管理员用户禁止在 Program Files 文件夹下写入文件.如果以非管理员用户身份运行的应用尝试在此处写入文件,并且该应用没有UAC清单,则Windows将保护 Program Files 文件夹,并以静默方式将所有访问重定向到VirtualStore文件夹在用户的个人资料中.

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.

Windows Vista或Windows 7中常见的文件和注册表虚拟化问题

Windows 7应用程序兼容性问题…神秘化!!!

在这种情况下,当您将INI写入此文件时:

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

您应该更改您的应用程序以将INI文件存储在更合适的位置,例如:

You should change your app to store the INI file in a more appropriate location, such as:

%LOCALAPPDATA%\MyProg\MyProg.ini

或者:

%PROGRAMDATA%\MyProg\MyProg.ini

查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆