如何在Visual Studio 2010的编译时嵌入清单文件 [英] How to embed a manifest file at compile time in 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:
- 嵌入"它.
- 使用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屋!