启动应用程序时显示 UAC 提示 [英] Show UAC prompt when launching an app

查看:44
本文介绍了启动应用程序时显示 UAC 提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序需要管理员权限才能执行某些操作.我只想在启动时显示 UAC 提示,然后提升.我不知道该怎么做,但我听说过诸如清单之类的事情,但在任何地方都没有看到明确的答案.

I have an app which needs administrator privileges to do some things. I'd like to just show the UAC prompt when it starts, and then be elevated. I'm not sure how to do this, but I'm hearing about things like manifests and whatnot but not seeing a plain answer anywhere.

推荐答案

您需要一个需要提升权限的应用清单.这是回答这个问题的博客引用:

You need an app manifest that demands elevated privileges. Here's a quote from a blog that answers this:

首先,您可以通过添加应用程序清单文件"项目到您的项目(默认名称:app.manifest),然后您可以通过项目属性"中的应用程序"选项卡进行设置.如果您想更改您的 Windows 用户帐户控制级别manifest 文件,你只需要设置 level 属性的值具有以下之一的 requestsExecutionLevel 节点:

First, you can create a manifest file by adding an "Application Manifest File" Item to your project (default name: app.manifest), then you can set it through the Application Tab in the Project Properties. If you want to change the Windows User Account Control level in your manifest file, all you need is to set the value of the level attribute of the requestedExecutionLevel node with one of the following:

  • asInvoker(默认):应用程序将使用当前的 Windows 用户权限运行
  • requireAdministrator:应用程序需要管理员用户
  • highestAvailable:将使用当前用户的最高权限

http://dariosantarelli.wordpress.com/2007/11/21/vs2008-embedding-uac-manifest-options/

这篇关于启动应用程序时显示 UAC 提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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