Application Manifest document

G

Guest

Can an application manifest document be added to a C# application? If so,
can it be done from within the IDE of Visual Studio 2005?

I want to customize my application's security level ("Administrator level")
and believe it has to be done from within this manifest file that is to be
linked into the program.
 
W

Willy Denoyette [MVP]

Steve Teeples said:
Can an application manifest document be added to a C# application? If so,
can it be done from within the IDE of Visual Studio 2005?

I want to customize my application's security level ("Administrator
level")
and believe it has to be done from within this manifest file that is to be
linked into the program.


An application manifest used to elevate the User privileges looks something
like this:

<?xml version="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="Read Security Log"
type="win32" />
<description>Read Security Events on Vista</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

this file must reside in the same folder as the exec file and must have the
name of the exec file with manifest appended. So if your exec file is named
like: MyApp.exe, your manifest must be named MyApp.exe.manifest.

To build an embedded assembly manifest that serves the same purpose as
above, you need to author a .rc file, with the following contents:

#include <winuser.h>
#define IDR_MANIFEST 1 // 2 for a DLL, 1 for an app
IDR_MANIFEST RT_MANIFEST MOVEABLE PURE
{
"<assembly xmlns=""urn:schemas-microsoft-com:asm.v1""
manifestVersion=""1.0"">
<asmv3:trustInfo xmlns:asmv3=""urn:schemas-microsoft-com:asm.v3"">
<asmv3:security>
<asmv3:requestedPrivileges>
<asmv3:requestedExecutionLevel
level=""requireAdministrator""
uiAccess=""false"" />
</asmv3:requestedPrivileges>
</asmv3:security>
</asmv3:trustInfo>
</assembly>"
}

This file has to be compiled into a binary resource using rc.exe (from the
platform SDK). You can do this from the command line or as a pre-step in
your VS project.
The resuting binary resource can be embedded using the /Win32res command
line switch, or by specifying the option for your VS project.

As I asked you before, you should post Vista development questions to the
Vista Development forums, these forums are specially set-up to answer
questions about the Vista Beta drops.

http://forums.microsoft.com/MSDN/default.aspx?forumgroupid=24&siteid=1

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top