围绕Windows UAC限制进行设计的正确方法? [英] Correct way to design around Windows UAC limitations?

查看:65
本文介绍了围绕Windows UAC限制进行设计的正确方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现,如果在任何级别启用UAC,我编写的应用程序在Windows Vista/7下均无法正常运行,因为它将文件写入程序的安装目录,默认为"C:\ Program Files \ MyProgram". "如果禁用了UAC(或在任何其他版本的Windows上),则UAC可以正常工作-我了解到,UAC默认情况下会拒绝应用程序对Program Files目录的写访问.

I found out an application I wrote does not work properly under Windows Vista/7 if UAC is enabled at any level, because it writes files to the install directory of the program, defaults to "C:\Program Files\MyProgram." If UAC is disabled (or on any other version of Windows) it works properly - I read that UAC denies applications write access to the Program Files directory by default.

我的问题是,我应该如何编写我的应用程序,以便可以在不需要任何权利"的情况下使用它.我不希望用户必须以提升的特权或以管理员身份运行它.我只是想让它工作.是否有某些应用程序可以在UAC下对某些目录进行写访问,在这些目录中写文件可能会更好些?它们主要是动态创建/销毁/更新的配置文件.

My question is, well, how should I write my application so that it can be used without any "rights" needed at all. I don't want users to have to run it with elevated privileges or as administrator. I just want it to work. Are there certain directories that any app has write access to under UAC where it might be better to write my files? They are mostly config files that are dynamically created/destroyed/updated.

感谢您的帮助!

推荐答案

应将每个用户应用程序特定的数据写入AppData文件夹中.

Per-user application specific data should be written in the AppData folder.

您应将 SHGetKnownFolderPath 与FOLDERID_LocalAppData一起使用.

You should use SHGetKnownFolderPath with FOLDERID_LocalAppData.

在托管代码中,您应该使用 System.Environment.GetFolderPath 使用System.Environment.SpecialFolder.LocalApplicationData.

In managed code, you should use System.Environment.GetFolderPath with System.Environment.SpecialFolder.LocalApplicationData.

这篇关于围绕Windows UAC限制进行设计的正确方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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