アプリケーションにマニフェストを追加するには、MyApp.manifest ファイルを作成してアプリケーション リソース ファイルに追加する必要があります。
//-- This define is normally part of the SDK but define it if this
//-- is an older version of the SDK.
#ifndef RT_MANIFEST
#define RT_MANIFEST 24
#endif
//-- Add the MyApp XP Manifest file
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "MyApp.manifest"
Visual Studioの新しいバージョンでは、プロジェクト設定に [マニフェスト ツール] タブがあり、このタブにある [追加のマニフェスト ファイル] フィールドを使用してマニフェスト ファイルを定義することもできます。
以下は、Win32 アプリケーション用の単純な MyApp.manifest ファイルです。
<?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.1"
processorArchitecture="X86"
name="Microsoft.Windows.MyApp"
type="win32"
/>
<description>MyApp</description>
</assembly>
アプリケーションが他の dll に依存している場合、これらの詳細をマニフェストに追加することもできます。Windows はこの情報を使用して、アプリケーションがこれらの依存 dll の正しいバージョンを常に使用するようにします。
たとえば、コモン コントロールとバージョン 8.0 C ランタイム ライブラリのマニフェスト依存関係の詳細は次のとおりです。
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.VC80.CRT"
version="8.0.50608.0"
processorArchitecture="x86"
publicKeyToken="1fc8b3b9a1e18e3b" />
</dependentAssembly>