我的程序需要将一些配置详细信息保存在 .ini 文件中。 该程序还安装 IE 和 Firefox 的扩展,我也想从这些扩展中读取这些 .ini 文件。 如果我将 .ini 保留在“...AppData/Roaming...”中,处于保护模式的 IE 扩展将无法读取/写入。 据我所知,只有 AppData/LocalLow 只能在保护模式下读取。 如果我将所有配置详细信息移至此“...AppData/LocalLoe...”,它会一直有效吗? 这是标准方式吗? 我写的所有内容都是在 Vista 环境中,它可以在 XP 中使用吗? Win7?
My program requires some configuration details to be kept in a .ini file. This program also installs extensions to IE and firefox and i want to read these .ini file from these extensions also. If I kept .ini in "...AppData/Roaming..." the IE extension in protected mode won't be able to read/write. As far as I know only AppData/LocalLow can only be able to read in protected mode. If I am moving all my configuration details to this "...AppData/LocalLoe..." will it work all times? Is this the std way? everything i written is in Vista context, will it work with XP? Win7?
发布评论
评论(2)
请参阅我对此问题的回答:如何决定在哪里存储每个用户的状态? 注册表? 应用程序数据? 独立存储?
引用此处:
Vista 中用户的“漫游”文件夹或 XP 中的“应用程序数据”文件夹中的文件随用户移动 - 因此任何设置和数据都应存储在那里。
Vista 中“Local”和“LocalLow”下的文件以及 XP 中“Local Settings”下的文件则不然,因此它是存放临时文件、与特定计算机相关的内容或可以重新计算的数据的好地方。
在 Vista 中,作为我们都知道和喜爱的新安全功能的一部分,您可以让程序在“低完整性模式”下运行(例如 IE 在保护模式下),这些程序以较低的权限运行,并且无法访问以下文件:用户的配置文件 - “LocalLow”文件夹下的文件除外。
因此,总而言之,存储在“LocalLow”中的文件本质上是不安全的,并且“本地”/“本地设置”中的文件在某些大公司中可能不可用 - 因此,除非您有充分的理由并且确切地知道自己在做什么,否则请选择“漫游”/“应用程序数据”。
更新:
See my answer to this question: How to decide where to store per-user state? Registry? AppData? Isolated Storage?
to quote from there:
Files in the User's "Roaming" folder in Vista or "Application Data" in XP move around with the user - so any settings and data should be stored there.
Files under "Local" and "LocalLow" in vista and "Local Settings" in XP do not, so it's a good place for temp files, things that are tied to the specific computer or data that can be recalculated.
In Vista, as part of the new security features we all know and love, you can have programs running in "low integrity mode" (for example IE in protected mode), those programs are running with reduced privileges and can't access files in the user's profile - except for files under the "LocalLow" folder.
So, in conclusion, files stored in "LocalLow" are inherently insecure and files in "Local"/"Local Settings" are likely to be unavailable in some large companies - so unless you have good reason and know exactly what you are doing go with "Roaming"/"Application Data".
UPDATE:
要获取程序数据的文件夹路径,您应该使用 WinAPI:
在 Windows Vista 中,函数 SHGetFolderPath 已替换为 SHGetKnownFoldedPath。 那个旧函数现在只是 SHGetKnownFolderPath 的包装器。
To get folder path for program data you should use WinAPI:
In Windows Vista function SHGetFolderPath was replaced with SHGetKnownFoldedPath. That older function is now simply a wrapper for SHGetKnownFolderPath.