# Tuesday, October 03, 2006


Under Vista, an application can have a manifest that identifies the privilege level it needs to run. These manifests can serve other purposes, too: they're also known as fusion manifests and can be used to identify dependencies among other things. Adding one to your application starts with adding a file to your project (right click and choose Add, New Item: depending on the language you're using you might be able to choose XML file or else Text file will do.) Then you put appropriate XML in it, like this:

<?xmlversion="1.0" encoding="utf-8" ?>
<
assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<
assemblyIdentity version="1.0.0.0"
processorArchitecture
="X86"
name
="Sample"
type
="win32" />
<
description>Sample Manifest Test Application</description>
<
trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<
security>
  <requestedPrivileges>
 <!--
<requestedExecutionLevel level="requireAdministrator" /> -->
 
<requestedExecutionLevel level="asInvoker" />
 <!--
<requestedExecutionLevel level="highestAvailable" /> -->
 </requestedPrivileges>
 </security>
 </trustInfo>
</
assembly>

You save the file as ApplicationName.exe.manifest. (When I intend to embed the manifest, I tend to call it app.manifest instead. If you plan to embed it, the filename doesn't really matter, but then if you change your mind and want an external manifest you'll need to remember to rename the file.)

At this point, you can follow the instructions in Catherine Heller's blog. The thing is, when I first read them I thought she skipped a step or something in explaining how to do it with Visual C++ 2005. After all, the other approaches had tons of steps!  There are .rc files, and .res files, and custom build steps, and unloading projects so you can open them differently, and never-mind-the-error-message notes, and all of that. And then for C++ it's just "open the project properties dialog, on the left-hand pane expand the Configuration Properties->Manifest Tool node and select Input and Output. You can enter the name of an external manifest file in the Additional Manifest Files field." But you know what? That's it! You make the manifest, put its name in the dialog, build the project.

Presto, your app has a manifest. Depending on the value you enter for requestedExecutionLevel and the account under which you run the app, you will see different behaviours at runtime.

Kate

Tuesday, October 03, 2006 7:35:51 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [3]