Dave's Brain

Browse - programming tips - embed manifest in your program

Date: 2010apr27
OS: Windows

Q.  How can I embed a manifest in my program?

A.  Starting with Vista manifests have two purposes (that I know of):

	- Turning on the Aero (glass) look of the controls

	- Turning on elevated security for your program when UAC is enabled

The manifest usually lives in a file called <YourProgram>.exe.manifest in
the same folder as your .cpp files.

For Aero make it contain this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
	<assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="<YourProgamHumanName>" type="win32" />
	
	<!-- the <description> tag is required but you don't have to fill it out -->
	<description></description>

	<!-- for Aero add this ... Usually you DO want this -->
	<dependency>
		<dependentAssembly>
			<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="X86" publicKeyToken="6595b64144ccf1df" language="*" />
		</dependentAssembly>
	</dependency>

	<!-- for elevated permissions add this... Usually you do NOT want this -->
	<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
		<security>
			<requestedPrivileges>
				<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
			</requestedPrivileges>
		</security>
	</trustInfo>

</assembly> 

Here's how you embed it in your program.

In Microsoft Visual C++ 2005 and later add it as add would a .cpp file
(under "Source Files") and it will be correctly embedded when you build.

In Borland C++ 5.02 open your .rc (resource) file in a text editor
and paste in:

	#define RT_MANIFEST 24
	#define APP_MANIFEST 1

	APP_MANIFEST RT_MANIFEST <YourProgram>.exe.manifest

and build.

It would be nice to be able to embed a manifest in a DLL.
Eg make your DLL use Aero when invoked by a older EXE (that doesn't have a
manifest).  You can embed a manifest in a DLL but my experiments have shown
that its ignored.  Maybe because the common controls are already initialized
by the time the DLL is called?
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2010, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.