在运行时请求管理员权限 [英] Requesting administrator privileges at run time

查看:346
本文介绍了在运行时请求管理员权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以让在Windows中运行的C ++应用程序在运行时从操作系统请求管理员权限?

Is it possible to get a C++ application running in Windows to request administrator privileges from the operating system at run time?

我知道它可以在编译时完成

I know it can be done at compile time, but can't seem to find anywhere whether it can be done at run time.

感谢您的帮助!

编辑:如果我想让当前实例具有提升的权限怎么办?例如,我可能有数据存储在内存中,我想保留。

What if I want the current instance to have elevated privileges? For example, I might have data stored in memory which I want to keep.

推荐答案

不完全,但你可以做相反 - 如果您已拥有权限,可以删除权限。因此,您可以使用 Kate Gregory 。然后,删除不需要的权限;请参阅在Windows上删除C ++中的权限 ,了解如何操作。

Not quite, but you can do the opposite—you can drop privileges if you already have them. So, you can have your program start out running as an Administrator, using one of the methods listed by Kate Gregory. Then, drop your unneeded privileges; see Dropping privileges in C++ on Windows for how to do that.

这篇关于在运行时请求管理员权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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