简体   繁体   English

为什么在W7中没有打开/写入/关闭路径为“ C:/ filename”的文件会返回失败?

[英]Why doesn't open/write/close on a file whose path is “C:/filename” return failure in W7?

I have a win32 program that I've supported for years. 我有一个已经支持多年的win32程序。 I just noticed that on W7 if it attempts to open/write/close a file directly in C:/, the system calls do not complain but the file is not created. 我只是注意到,在W7上,如果它尝试直接在C:/中打开/写入/关闭文件,则系统调用不会抱怨,但是不会创建文件。 I'm sure this has something to do with W7 security, but shouldn't the system calls return -1 to let the program know its not gonna work? 我确定这与W7安全性有关,但是系统调用不应该返回return -1来让程序知道它无法工作吗? It gets worse... After I realized that the system calls were not failing I figured I'd test for the presence of the file after the close() but that even succeeded! 情况变得更糟...当我意识到系统调用没有失败之后,我想我会在close()之后测试文件是否存在,但是甚至成功了! The file does not show up in explorer, but stat(c:/filename) says its there. 该文件未显示在资源管理器中,但stat(c:/ filename)在此处显示。 This path is set by the program user, so how can I detect that the file operation is not successful if every system call I try tells me it was successful? 该路径由程序用户设置,因此,如果我尝试的每个系统调用都告诉我成功,那么如何检测文件操作不成功?

The accesses got redirected to a private folder by UAC data redirection . 通过UAC数据重定向将访问重定向到专用文件夹。

That is a compatibility feature, giving programs pretend write access to the Windows directory and the system drive root, without compromising the system. 这是一项兼容性功能,可以使程序假装对Windows目录和系统驱动器根目录具有写权限,而不会损害系统。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM