在运行时请求管理员权限

发布于 2024-09-13 00:35:30 字数 33 浏览 2 评论 0原文

如何在运行时请求管理员权限,以便提示用户允许或禁止?

How do I request Administrator privileges during runtime so the user is given the prompt to allow or disallow it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

旧人哭 2024-09-20 00:35:30

如果您希望它响应按钮(例如,任务管理器中的“显示所有用户的进程”),您必须使用以下方法重新启动您的应用程序

ShellExecute(0,L"runas",exepath,0,0,SW_SHOWNORMAL);

if you want it in response to a button (eg, like 'show processes for all users' in task manager), you have to resart your app using the following method

ShellExecute(0,L"runas",exepath,0,0,SW_SHOWNORMAL);
碍人泪离人颜 2024-09-20 00:35:30

此信息写入 exe 文件清单中。您必须使用 requestedExecutionLevel 字段(但不确定 - 尝试将其设置为 highestAvailable 并查看它是否满足您的需要)。有关详细信息,请参阅此处的示例(有些较旧的文章但仍然有效): 链接

Visual中有工具Studio 允许您嵌入自己的清单,甚至可以编辑它。还有一个用 Perl 编写的工具( http://metacpan.org/pod/Win32 ::Exe::Manifest )。

编辑:有关详细信息,请参阅本文: http ://www.codeproject.com/Articles/66259/Requesting-Admin-Approval-at-Application-Start.aspx

This information is written in the exe file manifest. You must use the requestedExecutionLevel field (but not sure about that - try setting it to highestAvailable and see if it does what you need). See for example here for more information (somewhat older article but still valid): Link

There are tools in Visual Studio which allow you to embed your own manifest or even just edit it. Also there is a tool written in Perl ( http://metacpan.org/pod/Win32::Exe::Manifest ).

EDIT: see this article for more info: http://www.codeproject.com/Articles/66259/Requesting-Admin-Approval-at-Application-Start.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文