{"id":26623,"date":"2007-05-31T10:00:00","date_gmt":"2007-05-31T10:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2007\/05\/31\/visual-c-2005-will-generate-manifests-for-you\/"},"modified":"2007-05-31T10:00:00","modified_gmt":"2007-05-31T10:00:00","slug":"visual-c-2005-will-generate-manifests-for-you","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20070531-00\/?p=26623","title":{"rendered":"Visual C++ 2005 will generate manifests for you"},"content":{"rendered":"<p>\nNew in Visual C++ 2005 is the ability to\n<a HREF=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/ew0y5khy.aspx\">\nspecify a manifest\ndependency via a <code>#pragma<\/code> directive<\/a>.\nThis greatly simplifies using version&nbsp;6 of the shell\ncommon controls.\nYou just have to drop the line\n<\/p>\n<pre>\n<i>\/\/ do not use - see discussion below\n#pragma comment(linker, \\\n    \"\\\"\/manifestdependency:type='Win32' \"\\\n    \"name='Microsoft.Windows.Common-Controls' \"\\\n    \"version='6.0.0.0' \"\\\n    \"processorArchitecture='X86' \"\\\n    \"publicKeyToken='6595b64144ccf1df' \"\\\n    \"language='*'\\\"\")<\/i>\n<\/pre>\n<p>\ninto your program and the linker will do the rest.\n<\/p>\n<p>\nNote that the processor architecture is hard-coded into the\nabove directive, which means that if you are targetting\nx64, you&#8217;ll get the wrong manifest.\nTo fix that, we need to do some preprocessor munging.\n<\/p>\n<pre>\n#if defined(_M_IX86)\n#define MANIFEST_PROCESSORARCHITECTURE \"x86\"\n#elif defined(_M_AMD64)\n#define MANIFEST_PROCESSORARCHITECTURE \"amd64\"\n#elif defined(_M_IA64)\n#define MANIFEST_PROCESSORARCHITECTURE \"ia64\"\n#else\n#error Unknown processor architecture.\n#endif\n#pragma comment(linker, \\\n    \"\\\"\/manifestdependency:type='Win32' \"\\\n    \"name='Microsoft.Windows.Common-Controls' \"\\\n    \"version='6.0.0.0' \"\\\n    \"processorArchitecture='\" MANIFEST_PROCESSORARCHITECTURE \"' \"\\\n    \"publicKeyToken='6595b64144ccf1df' \"\\\n    \"language='*'\\\"\")\n<\/pre>\n<p>\n<b>Update<\/b>: I didn&#8217;t know that * is allowed here to indicate\n&#8220;all architectures&#8221;.\nThat simplifies matters greatly.\n<\/p>\n<pre>\n#pragma comment(linker, \\\n    \"\\\"\/manifestdependency:type='Win32' \"\\\n    \"name='Microsoft.Windows.Common-Controls' \"\\\n    \"version='6.0.0.0' \"\\\n    \"processorArchitecture='*' \"\\\n    \"publicKeyToken='6595b64144ccf1df' \"\\\n    \"language='*'\\\"\")\n<\/pre>\n<p>\n<b>Nitpicker&#8217;s corner<\/b>\n<\/p>\n<p>* That wasn&#8217;t a footnote marker.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>New in Visual C++ 2005 is the ability to specify a manifest dependency via a #pragma directive. This greatly simplifies using version&nbsp;6 of the shell common controls. You just have to drop the line \/\/ do not use &#8211; see discussion below #pragma comment(linker, \\ &#8220;\\&#8221;\/manifestdependency:type=&#8217;Win32&#8242; &#8220;\\ &#8220;name=&#8217;Microsoft.Windows.Common-Controls&#8217; &#8220;\\ &#8220;version=&#8217;6.0.0.0&#8242; &#8220;\\ &#8220;processorArchitecture=&#8217;X86&#8242; &#8220;\\ &#8220;publicKeyToken=&#8217;6595b64144ccf1df&#8217; &#8220;\\ [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-26623","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>New in Visual C++ 2005 is the ability to specify a manifest dependency via a #pragma directive. This greatly simplifies using version&nbsp;6 of the shell common controls. You just have to drop the line \/\/ do not use &#8211; see discussion below #pragma comment(linker, \\ &#8220;\\&#8221;\/manifestdependency:type=&#8217;Win32&#8242; &#8220;\\ &#8220;name=&#8217;Microsoft.Windows.Common-Controls&#8217; &#8220;\\ &#8220;version=&#8217;6.0.0.0&#8242; &#8220;\\ &#8220;processorArchitecture=&#8217;X86&#8242; &#8220;\\ &#8220;publicKeyToken=&#8217;6595b64144ccf1df&#8217; &#8220;\\ [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/26623","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=26623"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/26623\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=26623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=26623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=26623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}