{"id":27313,"date":"2007-04-10T10:00:00","date_gmt":"2007-04-10T10:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2007\/04\/10\/what-is-the-default-version-of-a-header-file\/"},"modified":"2007-04-10T10:00:00","modified_gmt":"2007-04-10T10:00:00","slug":"what-is-the-default-version-of-a-header-file","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20070410-00\/?p=27313","title":{"rendered":"What is the default version of a header file?"},"content":{"rendered":"<p>\nThe general rule with Windows header files is that if you don&#8217;t\nspecify which version of the header file you want,\nyou get the latest version.\nFor example, if you have the Windows&nbsp;XP Platform SDK header files\nand you <code>#include &lt;windows.h&gt;<\/code>,\nyou&#8217;re going to get the Windows&nbsp;XP function prototypes,\nthe Windows&nbsp;XP structures, the\nthe Windows&nbsp;XP flags, all that stuff.\nAnd unless you&#8217;re careful,\nthe program you get as a result will most likely run only\non Windows&nbsp;XP.\n<\/p>\n<p>\nIf you call a function that is new for Windows&nbsp;XP,\nthen your program won&#8217;t run on earlier versions of Windows\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2003\/09\/16\/54938.aspx\">\nbecause the import can&#8217;t be resolved<\/a>.&dagger;\n<\/p>\n<p>\nIf you use a structure that changed for Windows&nbsp;XP,\nthen your program won&#8217;t run on earlier versions of Windows\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2003\/12\/12\/56061.aspx\">\nbecause the structure size will be wrong<\/a>.\n<\/p>\n<p>\nEven if the structure size didn&#8217;t change, using a flag\nthat was introduced in Windows&nbsp;XP\nwill create difficulties for your program when run\non earlier versions of Windows\nbecause those earlier versions don&#8217;t support the flag you&#8217;re passing.\nDepending on how the function in question was written,\nit may ignore the &#8220;flag from the future&#8221; or it may reject it as invalid.\n<\/p>\n<p>\nIf you want your program to run on older versions of Windows,\nyou have a few options.\nFirst, you can explicitly &#8220;downgrade&#8221; your header file by\ndefining an appropriate symbol or symbols before including\nthe <code>windows.h<\/code> header file.\n<\/p>\n<pre>\n#define WINVER         0x0400\n#define _WIN32_WINNT   0x0400\n#define _WIN32_WINDOWS 0x0400\n#define _WIN32_IE      0x0400\n#include &lt;windows.h&gt;\n#include &lt;commctrl.h&gt;\n#include &lt;shlobj.h&gt;\n...\n<\/pre>\n<p>\nOh yuck, now we have the messy world of\n&#8220;So what&#8217;s the difference between\n<code>_WIN32_WINNT<\/code>,\n<code>_WIN32_WINDOWS<\/code>,\n<code>_WIN32_IE<\/code>, and\n<code>WINVER<\/code>?&#8221;\nWe&#8217;ll pick up this topic next time,\nbut you&#8217;re not going to like the answer.\n<\/p>\n<p>\n<b>Nitpicker&#8217;s corner<\/b>\n<\/p>\n<p>\n&dagger;That statement is from the operating system&#8217;s&Dagger; point of view.\nYou can of course use techniques like\nVisual Studio linker&#8217;s delay-load feature to avoid creating an import\ndependency, but that&#8217;s outside the operating system.&Dagger;\n<\/p>\n<p>\n&Dagger;s\/operating system\/Windows operating system\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The general rule with Windows header files is that if you don&#8217;t specify which version of the header file you want, you get the latest version. For example, if you have the Windows&nbsp;XP Platform SDK header files and you #include &lt;windows.h&gt;, you&#8217;re going to get the Windows&nbsp;XP function prototypes, the Windows&nbsp;XP structures, the the Windows&nbsp;XP [&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-27313","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>The general rule with Windows header files is that if you don&#8217;t specify which version of the header file you want, you get the latest version. For example, if you have the Windows&nbsp;XP Platform SDK header files and you #include &lt;windows.h&gt;, you&#8217;re going to get the Windows&nbsp;XP function prototypes, the Windows&nbsp;XP structures, the the Windows&nbsp;XP [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/27313","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=27313"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/27313\/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=27313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=27313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=27313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}