views:

49

answers:

2

New microsoft's IDEs like Visual Studio 2008 or 2010 creates exe files with manifest resource by default. But i still have some projects in Visual Studio 6 and i need to compile them to be maximum compatible with Win Vista and Win 7.
So i have many questions about manifest resources:
1. Is manifest resource required to create well-formed application for Win7 or WinVista?
2. What information is required in minimal manifest by WinVista and Win7?
3. Can wrong manifest resource trigger Program Compatibility Assistant under Windiws 7?
4. Is manifest resource required for DLL?
5. Where can i get information about using manifests?

+1  A: 

A couple of reasons you could need a manifest. First and foremost, you need one to tell Windows that your program is aware of UAC policies. That requires a manifest that contains the <requestedExecutionLevel> element. If that is missing, Windows will treat your program as a legacy program and redirect unsafe access to the registry and the file system. Writes to privileged registry keys are redirected to HKCU. File writes to privileged directories are redirected to isolated storage.

You'll need a manifest if your program is using DLLs that are stored in the Windows side-by-side cache. That is pretty unlikely to be the case if you still use VS6. WinSxS is used for the MFC and CRT libraries by VS2005 and VS2008 programs. But not VS2010, by popular demand from MSFT customers.

You'll need a manifest if you want to enable visual themes for your application. Required to load the modern version of the common controls from comctl32.dll version 6.0, stored in the side-by-side cache rather than the legacy version stored in system32.

And you need a manifest if you use registry-free COM, the manifest entries replace what is normally written to the registry, allowing for local deployment of in-process COM servers.

Most of this is automated in the modern versions of Visual Studio.

Hans Passant
+1  A: 

1. Is manifest resource required to create well-formed application for Win7 or WinVista?

Without a manifest (with a requestedExecutionLevel element) Windows Vista and Windows 7 use heuristics to try and guess if the application is a setup application - which means that a normal application might for no discernable reason start triggering UAC elevation propmpts.

requestedExecutionLevel also tells the system to NOT virtualize access to protected resources.

2. What information is required in minimal manifest by WinVista and Win7?

At least the requestedExecutionLevel so UAC knows canonically that you do - or do not - require elevation, and to not virtualize access to Program Files or HKLM.

3. Can wrong manifest resource trigger Program Compatibility Assistant under Windiws 7?

with a manifest, Windows vista and 7 will think you are a "modern" application that is merely broken. The Program compatibility Assistant logic is reserved for legacy applications - i.e. applications without a manifest or with with a manifest with XP only entries (i.e. lacking requestedExecutionLevel ).

4. Is manifest resource required for DLL?

As of windows 7 Only if the Dll uses it for binding to side-by-side assemblies. MSDev Studio creates manifests in Dlls with requestedExecutionLevel elements but this actually produces an invalid Dll that cannot be loaded successfully in some situations.

5. Where can i get information about using manifests?

On MSDN: Isolated Applications and Side By Side Assemblies is the only official reference I know of that even attempts to describe the manifest schema and how they can be used.


To summarize: If you are developing - and thus have presumably tested your apps behaviour - on Vista or Windows 7, it would be best if you included a manifest to avoid your application being treated as a legacy application.

Chris Becke