{"id":2423,"date":"2018-12-10T10:54:23","date_gmt":"2018-12-10T02:54:23","guid":{"rendered":"https:\/\/www.aoisnow.net\/blog\/?p=2423"},"modified":"2018-12-10T10:54:23","modified_gmt":"2018-12-10T02:54:23","slug":"tont-40633-%e4%b8%8d%e4%b8%a5%e8%b0%a8%e7%9a%84%e7%89%88%e6%9c%ac%e5%8f%b7%e6%a3%80%e6%9f%a5","status":"publish","type":"post","link":"https:\/\/www.aoisnow.net\/blog\/archives\/2423","title":{"rendered":"TONT 40633 \u4e0d\u4e25\u8c28\u7684\u7248\u672c\u53f7\u68c0\u67e5"},"content":{"rendered":"<p>\u957f\u5927\u4e86\uff0c\u6211\u624d\u77e5\u9053\uff0c\u5168\u56fd\u7684\u79c0\u624d\u90fd\u5ff5\u534a\u8fb9\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u539f\u6587\u94fe\u63a5\uff1a<a href=\"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/20040213-00\/?p=40633\" target=\"_blank\" rel=\"noopener\">https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/20040213-00\/?p=40633<\/a><\/p>\n<p>Version numbers. Very important. And so many people check them wrong.<\/p>\n<p>\u7248\u672c\u53f7\uff0c\u975e\u5e38\u91cd\u8981\uff0c\u5374\u62e6\u4e0d\u4f4f\u90a3\u4e48\u591a\u4eba\u7528\u9519\u8bef\u7684\u65b9\u5f0f\u505a\u68c0\u67e5\u3002<\/p>\n<p>This is why Windows 95&#8217;s GetVersion function returned 3.95 instead of 4.0. A lot of code checked the version number like this:<\/p>\n<p>\u8fd9\u5c31\u662fWindows 95\u7684GetVersion\u51fd\u6570\u4e3a\u4ec0\u4e48\u8fd4\u56de\u7684\u662f3.95\u800c\u4e0d\u662f4.0\u7684\u539f\u56e0\uff0c\u56e0\u4e3a\u8fd9\u4e16\u4e0a\u6709\u90a3\u4e48\u591a\u4ee3\u7801\u90fd\u662f\u5982\u4e0b\u8fd9\u6837\u68c0\u67e5\u7cfb\u7edf\u7684\u7248\u672c\u53f7\u7684\uff1a<\/p>\n<blockquote><p>UINT Ver = GetVersion();<br \/>\nUINT MajorVersion = LOBYTE(uVer);<br \/>\nUINT MinorVersion = HIBYTE(uVer);<br \/>\nif (MajorVersion &lt; 3 || MinorVersion &lt; 10) {<br \/>\nError(&#8220;This program requires Windows 3.1&#8221;); \/\/\u8bd1\u6ce8\uff1a\u610f\u4e3a\u300e\u6b64\u7a0b\u5e8f\u9700\u8981Windows 3.1\u300f<br \/>\n}<\/p><\/blockquote>\n<p>Now consider what happens when the version number is reported as 4.0. The major version check passes, but the minor version check fails since 0 is less than 10.<\/p>\n<p>\u73b0\u5728\u6765\u601d\u8003\u4e00\u4e0b\u4ee5\u4e0a\u4ee3\u7801\u9047\u5230\u7cfb\u7edf\u62a5\u544a\u76844.0\u7248\u672c\u53f7\u4f1a\u53d1\u751f\u4ec0\u4e48\u3002\u4e3b\u7248\u672c\u53f7\u68c0\u67e5\u901a\u8fc7\u4e86\uff0c\u4f46\u6b21\u7248\u672c\u53f7\u8fc7\u4e0d\u4e86\uff0c\u56e0\u4e3a0\u6bd410\u5c0f\u3002\uff08\u8bd1\u6ce8\uff1a\u6ce8\u610fMajorVersion\u548cMinorVersion\u4e4b\u95f4\u662f\u300e\u6216\u300f\u5173\u7cfb\uff09<\/p>\n<p>This bug was so rife that we gave up shimming every app that had the problem and just decided, &#8220;Fine. If anybody asks, say that the Windows version is 3.95.&#8221;<\/p>\n<p>\u8fd9\u4e2abug\u5b9e\u5728\u662f\u592a\u6d41\u884c\u4e86\uff0c\u4ee5\u81f3\u4e8e\u6211\u4eec\u5e72\u8106\u653e\u5f03\u4e86\u4e3a\u6bcf\u4e2a\u5b58\u5728\u8be5\u95ee\u9898\u7684\u5e94\u7528\u6253\u8865\u4e01\u7684\u505a\u6cd5\uff0c\u5e76\u51b3\u5b9a\uff1a\u300e\u00d7\u5b83\u3007\u7684\uff0c\u518d\u6709\u4eba\u95ee\uff0c\u5c31\u8bf4Windows\u7684\u7248\u672c\u662f3.95\u5f97\u4e86\u3002\u300f<\/p>\n<p>I suspect this is also <a href=\"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/archive\/2004\/01\/22\/61647.aspx#61840\" target=\"_blank\" rel=\"noopener\">why DirectX always reports its version as 4.x<\/a>.<\/p>\n<p>\u6211\u60f3\u8fd9\u4e5f\u662f\u4e3a\u4ec0\u4e48<a href=\"https:\/\/www.aoisnow.net\/blog\/archives\/2413\" target=\"_blank\" rel=\"noopener\">DirectX\u603b\u662f\u62a5\u544a\u5176\u7248\u672c\u4e3a4.x\u7684\u539f\u56e0<\/a>\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u957f\u5927\u4e86\uff0c\u6211\u624d\u77e5\u9053\uff0c\u5168\u56fd\u7684\u79c0\u624d\u90fd\u5ff5\u534a\u8fb9\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-2423","post","type-post","status-publish","format-standard","hentry","category-tont_history"],"_links":{"self":[{"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/posts\/2423","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/comments?post=2423"}],"version-history":[{"count":0,"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/posts\/2423\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/media?parent=2423"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/categories?post=2423"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/tags?post=2423"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}