"Steve Teeples" <St****@newsgro ups.nospam> wrote in message
news:0A******** *************** ***********@mic rosoft.com...
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 ("Administra tor
level")
and believe it has to be done from within this manifest file that is to be
linked into the program.
--
-----------
Thanks,
Steve
An application manifest used to elevate the User privileges looks something
like this:
<?xml version="1.0" encoding="utf-8" ?>
<assembly xmlns="urn:sche mas-microsoft-com:asm.v1" manifestVersion ="1.0">
<assemblyIdenti ty version="1.0.0. 0"
processorArchit ecture="X86"
name="Read Security Log"
type="win32" />
<description>Re ad Security Events on Vista</description>
<trustInfo xmlns="urn:sche mas-microsoft-com:asm.v3">
<security>
<requestedPrivi leges>
<requestedExecu tionLevel level="requireA dministrator" />
</requestedPrivil eges>
</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.manif est.
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:sch emas-microsoft-com:asm.v1""
manifestVersion =""1.0"">
<asmv3:trustInf o xmlns:asmv3=""u rn:schemas-microsoft-com:asm.v3"">
<asmv3:security >
<asmv3:requeste dPrivileges>
<asmv3:requeste dExecutionLevel
level=""require Administrator""
uiAccess=""fals e"" />
</asmv3:requested Privileges>
</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/def...id=24&siteid=1
Willy.