首次运行C程序作为管理员

发布于 2025-01-22 18:27:22 字数 1457 浏览 1 评论 0原文

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

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

发布评论

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

评论(1

清风夜微凉 2025-01-29 18:27:22

在内存中,同一程序的两个过程,也许让它们与管道通信。用户正常启动程序而没有提高特权。一旦需要高程,您就可以使用shellexecuteex和动词“ runas”开始相同的程序。这个“ runas”动词将导致UAC提示。

如果您在原始过程的整个过程中仅需要一次提高特权,则可以将一些参数传递到高架过程中,然后使用它。但是,如果您需要提高过程才能在不同的时间执行多个操作,那么您必须在两个过程之间打开管道,以将数据发送到提升过程。这样,您只需提示一次UAC,但是随时需要进行高程的工作。

Have in memory two processes of the same program, and maybe have them communicate with a pipe. The user starts the program normally without elevated privileges. Once the elevation is required you start the same program with ShellExecuteEx and verb "runas". This "runas" verb will cause UAC prompt.

If you need elevated privileges only once for the whole duration of the original process, then you can pass some parameters to the elevated process, and be done with it. But if you need elevated process to perform several actions, at different times, then you have to have a pipe open between two processes, to send data to the elevated process. This way you have UAC prompt only once, but do stuff that need elevation any time you need.

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