Windows 7是否像Vista一样限制文件夹访问? [英] Does Windows 7 restrict folder access as Vista does?

查看:142
本文介绍了Windows 7是否像Vista一样限制文件夹访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到在我的应用程序中,大多数兼容性问题是由某些文件夹的访问被拒绝"引起的,例如:

I noticed that in my application, most compatibility problems were caused by 'access denied' for some folders, such as:

Application Data [C:\ProgramData]
Desktop [C:\Users\Public\Desktop]
Documents [C:\Users\Public\Documents]
Favorites [C:\Users\Public\Favorites]
Start Menu [C:\ProgramData\Microsoft\Windows\Start Menu]
Templates [C:\ProgramData\Microsoft\Windows\Templates]

Windows 7与Vista是否存在相同的问题? 在Stack Overflow成员的帮助下,我知道在Vista上可以使用CSIDL_APPDATA启用文件访问,而不会出现UAC问题或访问被拒绝"错误. 这对Windows 7也有效吗?

Does Windows 7 have the same problem as Vista? With help from the members of Stack Overflow, I know that on Vista I can use CSIDL_APPDATA to enable the file access without UAC problems or 'access denied' errors. Is this also valid for Windows 7?

推荐答案

这不是问题",而是功能.它称为

It's not a "problem", it's a feature. It's called User Account Control (UAC), and it's one of the ways that system security was tightened under Windows Vista. Windows 7 indeed retains a similar security model.

您的应用程序首先完全不需要弄乱系统文件夹.如您所知,Windows为应用程序提供了许多临时和永久存储数据的位置.长期以来,Microsoft一直建议您利用这些文件夹:即使在以前的Windows版本下,它们也是存储数据的首选位置.您忽略了此建议,但您的应用程序仍可以继续工作的事实实际上是一个错误.更高版本的Windows最终关闭了该安全漏洞,从而破坏了您的应用程序,这一事实既不应意外也不应被忽视.

There's absolutely no reason that your application should need to mess with system folders in the first place. As you've already learned, Windows provides a number of locations for applications to store data, both temporarily and permanently. Microsoft has been recommending for a long time that you take advantage of these folders: they were the preferred location for storing data even under previous versions of Windows. The fact that you ignored this advice, yet your application continued to work, was actually the bug. The fact that later versions of Windows finally closed that security vulnerability, thus breaking your application, should be neither unexpected nor unappreciated.

您可以在此页面上找到有关在何处存储数据的更多信息.另请参见 Raymond Chen 提供了一个简单的方法,但很有启发性,概述了位置之间的差异:

You can find more information about where to store your data on this page. Also see this blog article, which attempts to summarize the array of technical documentation into a handy table. And as always, Raymond Chen provides a simple, yet instructive, overview of the differences between the locations:

我的文档"和应用程序数据"之间最重要的区别在于,我的文档"是用户存储文件的位置,而应用程序数据"是程序存储文件的位置.

The most important difference between My Documents and Application Data is that My Documents is where users store their files, whereas Application Data is where programs store their files.

换句话说,如果您在 CSIDL_MYDOCUMENTS (我的文档)中放置了某些内容,则应该期望用户重命名,移动,删除,将其通过电子邮件发送给他们的朋友,所有用户对文件的处理方式.因此,转到那里的文件应该是用户会识别为他们的东西"的东西.他们创建的文档,下载的音乐等等.

In other words, if you put something in CSIDL_MYDOCUMENTS (My Documents), you should expect the user to be renaming it, moving it, deleting it, emailing it to their friends, all the sorts of things users do with their files. Therefore, files that go there should be things that users will recognize as "their stuff". Documents they've created, music they've downloaded, that sort of thing.

另一方面,如果将某些内容放入 CSIDL_APPDATA (应用程序数据)中,则用户不太可能将其弄乱.在这里,您可以放置​​程序的支持数据,这些数据实际上并不是您希望用户弄乱的东西,但仍应与用户相关联.高分表,程序设置,自定义,拼写检查例外...

On the other hand, if you put something in CSIDL_APPDATA (Application Data), the user is less likely to be messing with it. This is where you put your program's supporting data that isn't really something you want the user messing with, but which should still be associated with the user. High score tables, program settings, customizations, spell check exceptions...

还有一个名为 CSIDL_LOCAL_APPDATA 的目录(本地设置\应用程序数据),其作用与CSIDL_APPDATA相似,不同之处在于如果用户配置文件漫游,该目录不会被复制. (本地设置"分支未复制为漫游用户配置文件的一部分.)将其视为按用户每计算机存储的位置.缓存和类似的非必要数据应保存在这里,特别是如果它们很大. %TEMP%和Internet临时文件目录是非漫游每用户数据的其他示例.

There is another directory called CSIDL_LOCAL_APPDATA (Local Settings\Application Data) which acts like CSIDL_APPDATA, except that it does not get copied if the user profile roams. (The "Local Settings" branch is not copied as part of the roaming user profile.) Think of it as a per-user-per-machine storage location. Caches and similar non-essential data should be kept here, especially if they are large. Other examples of non-roaming per-user data are your %TEMP% and Temporary Internet Files directories.

这篇关于Windows 7是否像Vista一样限制文件夹访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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