如何访问特殊文件? [英] How can I access to a special file?

查看:71
本文介绍了如何访问特殊文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我做了一个像资源管理器这样简单的程序!它运行良好,但在探索我的硬盘上的文件时,它停止了!



原因是它无法访问系统上的Users目录等特殊目录在Windows 7或8 OS上驱动C.每当我在Windows资源管理器上点击它时,都会出现拒绝访问消息!



如何在C ++代码中访问这些文件夹和文件?



等待你的答案!

Well, I've made a simple program like explorer!. It runs well, but during explore files on my hard disk, It stopped!

The reason is that it can not access to special directory like "Users" directory on system drive C on Windows 7 or 8 OS. Whenever I clicked it on Windows Explorer, "Access Denied" message appeared!

How can I access to those folders and files within C++ code?

Waiting your answers!

推荐答案

这个目录受到保护,而且很可能你真的不应该访问它。这一切都取决于你的目标。最有可能的是,您需要访问归属于用户帐户或所有用户的数据。如果是这样,那就是你必须使用的:

http://msdn.microsoft.com/en-us/library/windows/desktop/bb762181%28v=vs.85%29.aspx [ ^ ] ,

http:/ /msdn.microsoft.com/en-us/library/windows/desktop/dd378457%28v=vs.85%29.aspx [ ^ ]。



如果您确实需要访问需要提升权限的内容,则需要以管理员身份运行您的应用程序。请注意,以管理员身份登录是不够的。请参阅: http://www.sevenforums.com/tutorials/11841-run-administrator.html [ ^ ]。



在代码中,您所能做的就是创建并嵌入应用程序清单,该清单在一开始就通过UAC对话框请求提升:

http://msdn.microsoft.com/en-us/library/bb756929.aspx [ ^ ]。


-SA
This directory is protected, and, most likely, you really should not access it. It all depends on your goal. Most likely, you need to access the data attributed to a user account or to "all users". If this is so, this is what you have to use:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb762181%28v=vs.85%29.aspx[^],
http://msdn.microsoft.com/en-us/library/windows/desktop/dd378457%28v=vs.85%29.aspx[^].

If you really need to access something which need elevated privileges, you need to run your application "as administrator". Note that having logged as administrator would not be enough. Please see: http://www.sevenforums.com/tutorials/11841-run-administrator.html[^].

In code, all you can do is to create and embed application manifest which requests elevation through UAC dialog in the very beginning:
http://msdn.microsoft.com/en-us/library/bb756929.aspx[^].

Good luck,
—SA


你不能除非你的申请有更高的权利 - 这给了它是权限,但需要阿联酋的用户批准。



与Windows资源管理器完全相同:它无法打开用户不是烫发的文件夹可以访问。



您可以执行资源管理器的操作:捕获访问冲突异常并显示消息。
You can't unless your application has elevated rights - which gives it the permission, but which requires UAE for user approval.

Exactly the same as Windows Explorer: it can't open folders the user is not permitted to access.

You can do what Explorer does: catch the access violation exception and display a message.


这篇关于如何访问特殊文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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