如何在编译时在 Visual Studio 2010 中嵌入清单文件 [英] How to embed a manifest file at compile time in Visual Studio 2010

查看:33
本文介绍了如何在编译时在 Visual Studio 2010 中嵌入清单文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含以下节点的清单文件的项目:

I have a project with a manifest file with the following node:

 <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />

...意味着我希望它默认只以管理员身份"运行.

...meaning I want it to only run "as administrator" by default.

通过四处寻找,为了完成这项工作,我有两个选择:

from searching around, to make this work I have two options:

  1. 嵌入"它.
  2. 使用 exe 部署清单文件,并将其命名为 YourProject.exe.manifest.

我已经尝试了选项 2,当我运行我的应用程序时,它不要求管理员权限?

I've tried option 2, and when I run my app it doesn't ask for admin rights?

那么,我如何在 VS2010 中执行选项 1?我听说过 mt.exe,但这对我没有好处,因为它是在构建后完成的.我需要部分解决方案和项目文件本身的选项.

So, how do I do option 1 in VS2010? I've heard of mt.exe, but this is no good to me as it's done post build. I need the option to part of the solution and the project file itself.

那么,我该如何完成这项工作?我很乐意做 2,但它似乎不起作用?

So, how do I make this work? I'll be happy to do 2, but it doesn't seem to work?

推荐答案

在 Visual Studio 2010 中,新项目的默认设置是在应用程序中嵌入清单(选项 #1).默认情况下,虽然包含默认清单.您需要做的是添加自定义清单.

In Visual Studio 2010 the default setting for a new project is to embed the manifest in the application (option #1). By default though a default manifest is included. What you need to do is add a custom manifest.

  • 右键单击项目并选择添加新项目"
  • 选择应用程序清单文件"

这会将名为 app.manifest 的文件添加到项目中.打开该文件并将该行修改为以下内容

This will add a file named app.manifest to the project. Open that file and modify the line to be the following

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

这也应该适用于 Visual Studio 2008.

This should also work in Visual Studio 2008.

这篇关于如何在编译时在 Visual Studio 2010 中嵌入清单文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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