{"id":3033,"date":"2020-03-21T21:26:27","date_gmt":"2020-03-21T13:26:27","guid":{"rendered":"https:\/\/www.aoisnow.net\/blog\/?p=3033"},"modified":"2020-03-21T21:26:27","modified_gmt":"2020-03-21T13:26:27","slug":"tont-37523-%e8%b5%84%e6%ba%90%e7%ae%a1%e7%90%86%e5%99%a8%e6%98%af%e5%a6%82%e4%bd%95%e6%a3%80%e6%b5%8b%e4%bd%a0%e7%9a%84%e7%a8%8b%e5%ba%8f%e6%98%af%e5%90%a6%e6%94%af%e6%8c%81%e9%95%bf%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/www.aoisnow.net\/blog\/archives\/3033","title":{"rendered":"TONT 37523 \u8d44\u6e90\u7ba1\u7406\u5668\u662f\u5982\u4f55\u68c0\u6d4b\u4f60\u7684\u7a0b\u5e8f\u662f\u5426\u652f\u6301\u957f\u6587\u4ef6\u540d\u7684\uff1f"},"content":{"rendered":"<p>\u539f\u6587\u94fe\u63a5\uff1a<a href=\"https:\/\/devblogs.microsoft.com\/oldnewthing\/20041020-00\/?p=37523\" target=\"_blank\" rel=\"noopener\">https:\/\/devblogs.microsoft.com\/oldnewthing\/20041020-00\/?p=37523<\/a><\/p>\n<p>When you register your program with a file association, the shell needs to decide whether your program supports long file names so it can decide whether to pass you the long name (which may contains spaces! so make sure you put quotation marks around the \u201c%1\u201d in your registration) or the short name.<\/p>\n<p>\u5f53\u4f60\u4e3a\u81ea\u5df1\u7684\u5e94\u7528\u7a0b\u5e8f\u5efa\u7acb\u6587\u4ef6\u5173\u8054\u65f6\uff0c\u7cfb\u7edf\u9700\u8981\u77e5\u9053\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\u662f\u5426\u652f\u6301\u957f\u6587\u4ef6\u540d\uff0c\u8fd9\u6837\u624d\u80fd\u51b3\u5b9a\u662f\u5426\u5411\u4f60\u7684\u7a0b\u5e8f\u4f20\u9012\u957f\u6587\u4ef6\u540d\uff08\u53ef\u80fd\u4f1a\u5305\u542b\u7a7a\u683c\uff01\u6240\u4ee5\u8bf7\u4fdd\u8bc1\u5728\u6ce8\u518c\u6587\u4ef6\u5173\u8054\u65f6\u5728%1\u524d\u540e\u5305\u4e0a\u897f\u6587\u5f15\u53f7\uff09\u8fd8\u662f\u77ed\u6587\u4ef6\u540d\u3002<\/p>\n<p>The rule is simple: The shell looks at your program\u2019s EXE header to see what kind of program it is.<\/p>\n<p>\u89c4\u5219\u5f88\u7b80\u5355\uff1a\u7cfb\u7edf\u4f1a\u4f9d\u636e\u7a0b\u5e8fexe\u6587\u4ef6\u7684\u6587\u4ef6\u5934\u6765\u8fdb\u884c\u5224\u65ad\u3002<\/p>\n<ul>\n<li>If it is a 16-bit program, then the shell assumes that it supports long file names if it is marked as Windows 95-compatible. Otherwise, the shell assumes that it does not support long file anmes.<br \/>\n\u5982\u679c\u662f16\u4f4d\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u4e14\u6807\u8bb0\u4e3aWindows 95\u517c\u5bb9\uff0c\u7cfb\u7edf\u4f1a\u8ba4\u4e3a\u5176\u652f\u6301\u957f\u6587\u4ef6\u540d\uff0c\u5426\u5219\u8ba4\u4e3a\u4e0d\u652f\u6301\u3002\uff08\u8bd1\u6ce8\uff1aanmes\u7591\u4e3anames\u8bef\u690d\uff0c\u6b64\u5904\u539f\u6837\u4fdd\u7559\uff09<\/li>\n<li>If it is a 32-bit program (or 64-bit program for 64-bit systems), then the shell assumes that it supports long file names.<br \/>\n\u5982\u679c\u662f32\u4f4d\u5e94\u7528\u7a0b\u5e8f\uff08\u6216\u9762\u541164\u4f4d\u7cfb\u7edf\u768464\u4f4d\u5e94\u7528\u7a0b\u5e8f\uff09\uff0c\u7cfb\u7edf\u4f1a\u8ba4\u4e3a\u5176\u652f\u6301\u957f\u6587\u4ef6\u540d\u3002<\/li>\n<li>If it can\u2019t find your program, then the shell plays it safe and assumes that the program doesn\u2019t support long file names.<br \/>\n\u5982\u679c\u627e\u4e0d\u5230\u4f60\u7684\u7a0b\u5e8f\uff0c\u7cfb\u7edf\u4f1a\u4fdd\u5b88\u8d77\u89c1\u8ba4\u4e3a\u5176\u4e0d\u652f\u6301\u957f\u6587\u4ef6\u540d\u3002<\/li>\n<\/ul>\n<p>Note that third case. If you mess up your program registration, then the shell will be unable to determine whether your program supports long file names and assumes not. Then when your program displays the file name in, say, the title bar, you end up displaying some icky short file name alias instead of the proper long file name that the user expects to see.<\/p>\n<p>\u6ce8\u610f\u7b2c\u4e09\u79cd\u60c5\u51b5\u3002\u5982\u679c\u4f60\u6ce8\u518c\u6587\u4ef6\u5173\u8054\u7684\u65f6\u5019\u73a9\u8131\u4e86\uff0c\u90a3\u4e48\u7cfb\u7edf\u5c31\u65e0\u6cd5\u5224\u5b9a\u4f60\u7684\u7a0b\u5e8f\u662f\u5426\u652f\u6301\u957f\u6587\u4ef6\u540d\uff0c\u5e76\u5047\u5b9a\u5176\u4e0d\u652f\u6301\u3002\u8fd9\u6837\u5982\u679c\u4f60\u7684\u7a0b\u5e8f\u5728\u67d0\u4e9b\u5730\u65b9\u663e\u793a\u6587\u4ef6\u540d\uff08\u6bd4\u5982\u6807\u9898\u680f\uff09\u7684\u8bdd\uff0c\u5c31\u4f1a\u663e\u793a\u6210\u90a3\u79cd\u770b\u4e0a\u53bb\u5f88\u8ba8\u538c\u7684\u77ed\u6587\u4ef6\u540d\u522b\u540d\uff0c\u800c\u4e0d\u662f\u7528\u6237\u671f\u671b\u770b\u5230\u7684\u957f\u6587\u4ef6\u540d\u3002<\/p>\n<p>The most common way people mess up their program registration is by forgetting to quote spaces in the path to the program itself! For example, an erroneous registration might go something like this:<\/p>\n<p>\u6700\u5e38\u89c1\u73a9\u8131\u6ce8\u518c\u6587\u4ef6\u5173\u8054\u7684\u65b9\u5f0f\uff0c\u662f\u5fd8\u8bb0\u5c06\u7a0b\u5e8f\u8def\u5f84\u5305\u542b\u5728\u5f15\u53f7\u7684\u91cc\u9762\uff01\u4f8b\u5982\uff0c\u67d0\u7a0b\u5e8f\u9519\u8bef\u5730\u6ce8\u518c\u6587\u4ef6\u5173\u8054\u7684\u60c5\u51b5\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<blockquote><p><strong>HKEY_CLASSES_ROOT\\litfile\\shell\\open\\command<\/strong><\/p>\n<p>(default) = C:\\Program Files\\LitWare Deluxe\\litware.exe \u201c%1\u201d<\/p><\/blockquote>\n<p>Observe that the spaces in the path \u201cC:\\Program Files\\Litware Deluxe\\litware.exe\u201d are not quoted in the program registration. Consequently, the shell mistakenly believes that the program name is \u201cC:\\Program\u201d, which it cannot find. The shell therefore plays it safe and assumes no LFN support.<\/p>\n<p>\u6ce8\u610f\u89c2\u5bdf\u7a0b\u5e8f\u8def\u5f84\u300eC:\\Program Files\\Litware Deluxe\\litware.exe\u300f\u5e76\u6ca1\u6709\u7528\u5f15\u53f7\u62ec\u8d77\u6765\u3002\u7531\u6b64\uff0c\u7cfb\u7edf\u4fbf\u9519\u8bef\u5730\u8ba4\u4e3a\u7a0b\u5e8f\u7684\u540d\u79f0\u662f\u300eC:\\Program\u300f\uff0c\u5e76\u4e14\u4e5f\u627e\u4e0d\u5230\u5bf9\u5e94\u7684\u6587\u4ef6\uff0c\u6240\u4ee5\u7cfb\u7edf\u51b3\u5b9a\u4fdd\u5b88\u8d77\u89c1\uff0c\u8ba4\u4e3a\u8fd9\u4e2a\u7a0b\u5e8f\u4e0d\u652f\u6301\u957f\u6587\u4ef6\u540d\u3002<\/p>\n<p>Compatibility note: As part of other security work, the code in the shell that parses these command lines was augmented to chase down the \u201cintended\u201d path of the program. This presented the opportunity to fix that third case, so that the shell could find the program after all and see that it supported long file names, thereby saving the user the ignominy of seeing their wonderful file name turn into a mush of tildes.<\/p>\n<p>\u8fd9\u91cc\u6709\u4e00\u4e2a\u517c\u5bb9\u6027\u76f8\u5173\u7684\u5c0f\u6545\u4e8b\uff1a\u4f5c\u4e3a\u5b89\u5168\u65b9\u9762\u8003\u91cf\u7684\u4e00\u73af\uff0c\u7cfb\u7edf\u4e2d\u6709\u5173\u5904\u7406\u8fd9\u4e9b\u547d\u4ee4\u884c\u7684\u4ee3\u7801\u66fe\u88ab\u8981\u6c42\u53ef\u4ee5\u4e3b\u52a8\u627e\u51fa\u5bf9\u5e94\u7a0b\u5e8f\u300e\u539f\u672c\u300f\u7684\u8def\u5f84\u3002\u8fd9\u6837\u7684\u8bbe\u8ba1\u63d0\u4f9b\u4e86\u4e00\u79cd\u5bf9\u524d\u8ff0\u7b2c\u4e09\u79cd\u60c5\u51b5\u8865\u6551\u7684\u673a\u4f1a\uff0c\u7cfb\u7edf\u53ef\u80fd\u56e0\u6b64\u627e\u5230\u5bf9\u5e94\u7684\u7a0b\u5e8f\u6587\u4ef6\uff0c\u5e76\u5b9e\u9645\u5224\u65ad\u5176\u662f\u5426\u652f\u6301\u957f\u6587\u4ef6\u540d\uff0c\u5982\u6b64\u4e00\u6765\u7528\u6237\u5c31\u4e0d\u4f1a\u5bf9\u5176\u7f8e\u5999\u7684\u6587\u4ef6\u540d\u53d8\u6210\u4e00\u5806\u5c0f\u6d6a\u82b1\uff08\u8bd1\u6ce8\uff1a~\u7b26\u53f7\uff0c\u957f\u6587\u4ef6\u540d\u538b\u7f29\u5230\u77ed\u6587\u4ef6\u540d\u65f6\u7528\u4ee5\u533a\u522b\u591a\u4e2a\u538b\u7f29\u540e\u540c\u540d\u6587\u4ef6\u7684\u673a\u5236\u4e4b\u4e00\uff0c\u5f62\u5982FILENA~1.DOC\u3001FILENA~2.DOC\u7b49\uff09\u800c\u5e72\u77aa\u773c\u4e86\u3002<\/p>\n<p>And after we made the change, we had to take it out.<\/p>\n<p>\u6211\u4eec\u5728\u505a\u51fa\u8fd9\u6837\u7684\u6539\u8fdb\u540e\uff0c\u53c8\u4e0d\u5f97\u4e0d\u5c06\u5176\u64a4\u4e86\u4e0b\u6765\u3002<\/p>\n<p>Because there were programs that not only registered themselves incorrectly, but were relying on the shell not being smart enough to find their real location, resulting in the program receiving the short name on the command line. Turns out these programs wanted the short name, and doing this fake-out was their way of accomplishing it.<\/p>\n<p>\u56e0\u4e3a\uff08\u8fd9\u6837\u6539\u8fdb\u4e4b\u540e\uff09\u67d0\u4e9b\u5e94\u7528\u7a0b\u5e8f\u4e0d\u5149\u4e0d\u7528\u6b63\u786e\u7684\u65b9\u5f0f\u53bb\u6ce8\u518c\u6587\u4ef6\u5173\u8054\uff0c\u751a\u81f3\u8fd8\u4f9d\u8d56\u8fd9\u79cd\u539f\u5148\u7cfb\u7edf\u65e0\u6cd5\u627e\u5230\u5176\u7a0b\u5e8f\u6587\u4ef6\u7684\u7f3a\u9677\uff0c\u7531\u6b64\u4f7f\u7cfb\u7edf\u4f20\u77ed\u6587\u4ef6\u540d\u8fdb\u53bb\u3002\u6211\u4eec\u53d1\u73b0\u8fd9\u4e2a\u7a0b\u5e8f\u5c31\u662f\u60f3\u8981\u77ed\u6587\u4ef6\u540d\uff0c\u800c\u5b83\u5219\u662f\u7528\u8fd9\u79cd\u6b3a\u9a97\u7684\u624b\u6bb5\u6765\u8fbe\u6210\u76ee\u7684\u7684\u3002<\/p>\n<p>(And to those of you who are already shouting, \u201cGo ahead and break them,\u201d that\u2019s all fine and good as long as the thing that\u2019s incompatible isn\u2019t something you use. But if it\u2019s your program, or a program your company relies on, I expect you\u2019re going to change your tune.)<\/p>\n<p>\uff08\u6b64\u5916\uff0c\u5bf9\u90a3\u4e9b\u6b64\u65f6\u5df2\u7ecf\u5728\u5927\u558a\u300e\u90a3\u5c31\u522b\u7ba1\u4ed6\u4eec\u554a\u300f\u7684\u4eba\u4eec\uff0c\u53ea\u8981\u8fd9\u4e0d\u662f\u4f60\u975e\u7528\u4e0d\u53ef\u7684\u8f6f\u4ef6\uff0c\u600e\u4e48\u6837\u90fd\u662f\u597d\u7684\u3002\u4f46\u5982\u679c\u8fd9\u6837\u505a\u7684\u5c31\u662f\u4f60\u7684\u8f6f\u4ef6\uff0c\u6216\u8005\u4f60\u4eec\u516c\u53f8\u4f9d\u8d56\u7684\u8f6f\u4ef6\uff0c\u6211\u5f88\u4e50\u610f\u770b\u5230\u4f60\u6536\u56de\u4f60\u7684\u8bf4\u6cd5\u3002\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u6587\u94fe\u63a5\uff1ahttps:\/\/devblogs.microsoft.com\/oldnewthing\/2004102 [&hellip;]<\/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-3033","post","type-post","status-publish","format-standard","hentry","category-tont_history"],"_links":{"self":[{"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/posts\/3033","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=3033"}],"version-history":[{"count":0,"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/posts\/3033\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/media?parent=3033"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/categories?post=3033"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/tags?post=3033"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}