我想让我的程序在尝试在受保护的位置(如C:\驱动器的根目录)创建文件时发出错误(例如:FILE* FileHandle = fopen("\\file.txt", a)
)。而是在%APPDATA%下的虚拟存储中创建文件。如何禁用C++程序的VirtualStore?
如何禁用该虚拟商店?
感谢
编辑:只是要清楚,我不问如何规避安全和受保护的位置创建我的文件。我希望文件创建失败,以便我可以告诉用户他是个白痴。
我想让我的程序在尝试在受保护的位置(如C:\驱动器的根目录)创建文件时发出错误(例如:FILE* FileHandle = fopen("\\file.txt", a)
)。而是在%APPDATA%下的虚拟存储中创建文件。如何禁用C++程序的VirtualStore?
如何禁用该虚拟商店?
感谢
编辑:只是要清楚,我不问如何规避安全和受保护的位置创建我的文件。我希望文件创建失败,以便我可以告诉用户他是个白痴。
您添加应用程序清单。选择asInvoker,highestAvailable或requireAdministrator。这听起来像你想要的InVoker。
从http://msdn.microsoft.com/en-us/library/bb756929.aspx:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0"
processorArchitecture="X86"
name="IsUserAdmin"
type="win32"/>
<description>Description of your application</description>
<!-- Identify the application security requirements. -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="asInvoker"
uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
是的,带有'
从MSDN:
虚拟化仅启用
虚拟化是停用:
你会正如Adam Maras指出的那样,下注是通过添加清单来为应用程序设置一个requestedExecutionLevel。 “asInvoker”的requestedExecutionLevel将导致文件操作在受保护位置失败,而不是重定向到虚拟商店或提示提升。
这是一篇文章,显示如何关闭虚拟化。
http://www.interworks.com/blogs/dsmith/2011/09/21/disabling-windows-7-virtual-store
这样做的缺点是:
- 从Windows 7开始球,做本地安全策略的搜索,并选择它。
-Expand Local Policies并单击安全选项。在右侧窗格中,一直滚动到底部,您会发现一个名为“用户帐户控制:虚拟化文件和注册表写入每个用户位置的故障”的设置,双击该设置并将其更改为禁用。
@ BenVoigt感谢您的提醒。我没有看过这个年龄段的问题 – 2013-12-30 20:48:02