在Windows中设置用户访问权限 [英] Setting User Access Rights in Windows

查看:205
本文介绍了在Windows中设置用户访问权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我如何在Delphi 2006中设置文件权限吗?我正在使用TINIFile.Create在我的应用程序中创建INI文件。问题是,如果我以管理员身份登录Windows时创建了文件,然后尝试仅以标准用户身份运行该应用程序并覆盖INI文件,则我无权这样做。我将文件放在AllUsers\ApplicationData\MyProduct文件夹中。我想为此文件夹设置权限。我需要AllUsers对MyProduct文件夹具有完全权限。如果可以通过WindowsAPI做到这一点,那将是个好主意,因为我还需要使用C ++和C#进行此操作。非常感谢您的帮助。谢谢!

Can someone tell me how to set file permissions in Delphi 2006? I am using TINIFile.Create to create INI files in my application. The problem is that if I create the file while logged onto Windows as an administrator and then try to run the application as just a standard user and overwrite the INI file, I do not have permission to do so. I put the file in the AllUsers\ApplicationData\MyProduct folder. I'd like to set the permissions to this folder. I need AllUsers to have Full permissions to the MyProduct folder. If its possible to do this through a WindowsAPI that'd be great because I also need to do this in C++ and C#. I'd really appreciate any help. Thanks!

推荐答案

尽管您可以使用Delphi(作为管理员)中的正确代码进行各种权限更改,但应用程序结构更好并不是要假设您的应用程序具有任何特权(您说您希望它在用户模式下运行)。而是使用将安装您的应用程序的安装程序(例如Inno Setup)将合适的Ini文件模板复制到所需的数据文件夹中。您可以在文件复制行上使用权限:用户修改来指定所需的权限。

Although you can do all sorts of permission changes with the right code in Delphi (as admin) a better application structure is to NOT assume that your App has any privileges (you say you want it to run in user mode). Instead, use the installer that will install your App (e.g Inno Setup) to copy a suitable Ini file template into your required data folder. You can specify the permissions that you want using "Permissions: user-modify" on the file copy line.

这篇关于在Windows中设置用户访问权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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