{"id":2926,"date":"2019-10-03T23:55:42","date_gmt":"2019-10-03T15:55:42","guid":{"rendered":"https:\/\/www.aoisnow.net\/blog\/?p=2926"},"modified":"2019-10-03T23:55:42","modified_gmt":"2019-10-03T15:55:42","slug":"tont-38493-%e3%80%8e%e6%b7%bb%e5%8a%a0-%e5%88%a0%e9%99%a4%e7%a8%8b%e5%ba%8f%e3%80%8f%e6%98%af%e5%a6%82%e4%bd%95%e8%8e%b7%e7%9f%a5%e5%ba%94%e7%94%a8%e7%a8%8b%e5%ba%8f%e7%9a%84%e5%a4%a7%e5%b0%8f","status":"publish","type":"post","link":"https:\/\/www.aoisnow.net\/blog\/archives\/2926","title":{"rendered":"TONT 38493 \u300e\u6dfb\u52a0\/\u5220\u9664\u7a0b\u5e8f\u300f\u662f\u5982\u4f55\u83b7\u77e5\u5e94\u7528\u7a0b\u5e8f\u7684\u5927\u5c0f\u7b49\u4fe1\u606f\u7684\uff1f"},"content":{"rendered":"<p>\u539f\u6587\u94fe\u63a5\uff1a<a href=\"https:\/\/devblogs.microsoft.com\/oldnewthing\/20040709-00\/?p=38493\" target=\"_blank\" rel=\"noopener\">https:\/\/devblogs.microsoft.com\/oldnewthing\/20040709-00\/?p=38493<\/a><\/p>\n<p>If the program doesn\u2019t provide this information itself, Add\/Remove Programs is forced to guess.<\/p>\n<p>\u5982\u679c\u5e94\u7528\u7a0b\u5e8f\u6ca1\u6709\u4e3b\u52a8\u63d0\u4f9b\u8fd9\u4e9b\u4fe1\u606f\uff0c\u300e\u6dfb\u52a0\/\u5220\u9664\u7a0b\u5e8f\u300f\u4e0d\u5f97\u5df2\u5c31\u5f97\u7528\u731c\u7684\u4e86\u3002<\/p>\n<p>The problem is that there is no \u201cobvious\u201d way to map an entry in the Add\/Remove Programs list to an actual program. Each entry in the list, for those who care about such things, comes from the HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall registry key. The only mandatory properties for an uninstallable program are the DisplayName and the UninstallPath. Everything else is optional.<\/p>\n<p>\u95ee\u9898\u5728\u4e8e\uff0c\u300e\u6dfb\u52a0\/\u5220\u9664\u7a0b\u5e8f\u300f\u5e76\u6ca1\u6709\u4e00\u79cd\u660e\u786e\u7684\u624b\u6bb5\u5c06\u4e00\u9879\uff08\u5df2\u5b89\u88c5\u7a0b\u5e8f\u7684\uff09\u6761\u76ee\u4e0e\u5b9e\u9645\u7684\u5e94\u7528\u7a0b\u5e8f\u5173\u8054\u8d77\u6765\u3002\u4e3a\u5173\u6ce8\u76f8\u5173\u4e8b\u9879\u7684\u4eba\u670d\u52a1\u4e00\u628a\uff1a\uff08\u300e\u6dfb\u52a0\/\u5220\u9664\u7a0b\u5e8f\u300f\u4e2d\u7684\uff09\u6bcf\u4e00\u4e2a\u6761\u76ee\u90fd\u53d6\u81ea\u6ce8\u518c\u8868\u952e\u00a0HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\u3002\u5bf9\u4e8e\u6bcf\u4e2a\u53ef\u4ee5\u5378\u8f7d\u7684\u5e94\u7528\u7a0b\u5e8f\u800c\u8a00\uff0c\u5fc5\u9700\u7684\u6761\u76ee\u662f\u00a0DisplayName \u548c\u00a0UninstallPath\uff0c\u5269\u4e0b\u7684\u90fd\u662f\u53ef\u9009\u9879\u3002<\/p>\n<p>Let\u2019s suppose Add\/Remove Programs is given a program registration like this:<\/p>\n<p>\u5047\u8bbe\u6709\u4ee5\u4e0b\u6ce8\u518c\u8868\u4fe1\u606f\u88ab\u7ed9\u4e88\u4e86\u300e\u6dfb\u52a0\/\u5220\u9664\u7a0b\u5e8f\u300f\uff1a<\/p>\n<p>HKEY_LOCAL_MACHINE\\<br \/>\nSoftware\\<br \/>\nMicrosoft\\<br \/>\nWindows\\<br \/>\nCurrentVersion\\<br \/>\nUninstall\\<br \/>\nSomeProgram<br \/>\nDisplayName=REG_SZ:&#8221;Awesome Program for Windows&#8221;<br \/>\nUninstallPath=REG_SZ:&#8221;C:\\WINDOWS\\uninstall.exe -SomeParameters&#8221;<\/p>\n<p>In order to get the \u201cLast Used\u201d and \u201cFrequency\u201d values, Add\/Remove Programs needs to know the name of the EXE so it can ask the Start menu \u201cHey, how often did the user run this program, and when was the last time it happened?\u201d<\/p>\n<p>\u4e3a\u4e86\u83b7\u53d6\u300e\u6700\u8fd1\u4f7f\u7528\u65f6\u95f4\u300f\u548c\u300e\u4f7f\u7528\u9891\u7387\u300f\u7684\u503c\uff0c\u300e\u6dfb\u52a0\/\u5220\u9664\u7a0b\u5e8f\u300f\u9700\u8981\u77e5\u9053\u5e94\u7528\u7a0b\u5e8f\u4e3b\u7a0b\u5e8f\u7684EXE\u6587\u4ef6\u540d\uff0c\u8fd9\u6837\u624d\u80fd\u5411\u5f00\u59cb\u83dc\u5355\u54a8\u8be2\uff1a\u300e\u55e8\uff0c\u7528\u6237\u6709\u591a\u7ecf\u5e38\u8fd0\u884c\u8fd9\u4e2a\u5e94\u7528\u7a0b\u5e8f\uff0c\u4e0a\u6b21\u8fd0\u884c\u53c8\u662f\u4ec0\u4e48\u65f6\u5019\u7684\u4e8b\u60c5\u5440\uff1f\u300f<\/p>\n<p>Notice that there are no clues in the registration above as to the identity of this EXE file.<\/p>\n<p>\u8bf7\u6ce8\u610f\uff0c\u4e0a\u8ff0\u6ce8\u518c\u8868\u4fe1\u606f\u4e2d\uff0c\u5e76\u65e0\u8fa8\u8ba4\u5e94\u7528\u7a0b\u5e8f\u4e3b\u7a0b\u5e8fEXE\u6587\u4ef6\u7684\u7ebf\u7d22\u3002<\/p>\n<p>So Add\/Remove Programs starts guessing. It goes through all the programs on your Start menu and compares their names with the display name of the uninstallable item. It looks for Start menu items which share at least two words with the words in the DisplayName.<\/p>\n<p>\u4e8e\u662f\u300e\u6dfb\u52a0\/\u5220\u9664\u7a0b\u5e8f\u300f\u5c31\u5f00\u59cb\u9760\u731c\u7684\u4e86\u3002\u300e\u6dfb\u52a0\/\u5220\u9664\u7a0b\u5e8f\u300f\u904d\u5386\u5f00\u59cb\u83dc\u5355\uff0c\u5c06\u4e0a\u8ff0\u6ce8\u518c\u8868\u4fe1\u606f\u63d0\u4f9b\u7684\u3001\u53ef\u5378\u8f7d\u5e94\u7528\u7a0b\u5e8f\u7684\u300e\u663e\u793a\u540d\u79f0\u300f\u4e0e\u5f00\u59cb\u83dc\u5355\u4e2d\u7684\u6761\u76ee\u8fdb\u884c\u6bd4\u8f83\uff0c\u6807\u51c6\u662f\u6709\u81f3\u5c11\u4e24\u4e2a\u5355\u8bcd\u4e0e\u00a0DisplayName \u76f8\u540c\u3002<\/p>\n<p>For example, if there were a Start menu item called \u201cPretty Decent Windows Program\u201d, this would count as a two-word match (\u201cWindows\u201d and \u201cProgram\u201d).<\/p>\n<p>\u4f8b\u5982\uff0c\u5982\u679c\u6709\u4e00\u4e2a\u5f00\u59cb\u83dc\u5355\u6761\u76ee\u53eb\u300ePretty Decent Windows Program\u300f\uff0c\u8fd9\u6837\u5c31\u7b97\u6709\u4e24\u4e2a\u5355\u8bcd\u76f8\u7b26\uff08Windows \u548c Program\uff09\uff08\u8bd1\u6ce8\uff1a\u524d\u4f8b\u4e2d\u7684 DisplayName \u53eb Awesome Program for Windows\uff09\u4e86\u3002<\/p>\n<p>It then takes the one with the most matches and decides, \u201cOkay, I guess this is it.\u201d Suppose for the sake of illustration that the best match is indeed \u201cPretty Decent Windows Program.lnk\u201d, which is a shortcut to \u201cC:\\Program Files\\LitWare\\Decent Program\\Decent.exe\u201d. Add\/Remove Programs would decide that \u201cAwesome Program for Windows\u201d should get the icon for \u201cPretty Decent Windows Program.lnk\u201d, that the frequency of use and most-recently-used information for \u201cC:\\Program Files\\LitWare\\Decent Program\\Decent.exe\u201d will be displayed for \u201cAwesome Program for Windows\u201d.<\/p>\n<p>\u300e\u6dfb\u52a0\/\u5220\u9664\u7a0b\u5e8f\u300f\u4f1a\u6311\u9009\u76f8\u4f3c\u7a0b\u5ea6\u6700\u9ad8\u7684\u4e00\u9879\uff0c\u7136\u540e\u4e0b\u5b9a\u51b3\u5fc3\u8bf4\uff1a\u300e\u884c\u4e86\uff0c\u4f9d\u6211\u770b\u5c31\u662f\u5b83\u4e86\u3002\u300f\u5047\u8bbe\u5728\u672c\u4f8b\u4e2d\uff0c\u76f8\u4f3c\u7a0b\u5ea6\u6700\u9ad8\u7684\u4e00\u9879\u6b63\u597d\u662f\u300ePretty Decent Windows Program.lnk\u300f\uff0c\u800c\u5b83\u662f\u5230\u300eC:\\Program Files\\LitWare\\Decent Program\\Decent.exe\u300f\u7684\u5feb\u6377\u65b9\u5f0f\uff0c\u300e\u6dfb\u52a0\/\u5220\u9664\u7a0b\u5e8f\u300f\u4fbf\u7531\u6b64\u51b3\u5b9a\u300eAwesome Program for Windows\u300f\u5e94\u5f53\u91c7\u7528\u300ePretty Decent Windows Program.lnk\u300f\u7684\u56fe\u6807\uff0c\u800c\u4f7f\u7528\u9891\u7387\u548c\u6700\u8fd1\u4f7f\u7528\u65f6\u95f4\u7684\u4fe1\u606f\u5219\u53d6\u81ea\u300eC:\\Program Files\\LitWare\\Decent Program\\Decent.exe\u300f\u3002<\/p>\n<p>But wait, there\u2019s more. There\u2019s also the program size. Add\/Remove Programs looks in your \u201cProgram Files\u201d directory for directories whose names share at least two words in common with the DisplayName. The best match is assumed to be the directory that the program files are installed into. The sizes are added together and reported as the size of \u201cAwesome Program for Windows\u201d.<\/p>\n<p>\u4e0d\u8fc7\u7b49\u7b49\uff0c\u8fd8\u6ca1\u5b8c\u3002\u8fd8\u6709\u4e00\u9879\u4fe1\u606f\u53eb\u300e\u5927\u5c0f\u300f\u3002\u300e\u6dfb\u52a0\/\u5220\u9664\u7a0b\u5e8f\u300f\u5c06\u5728\u300eProgram Files\u300f\u76ee\u5f55\u4e2d\u67e5\u627e\u4e0e\u00a0DisplayName \u6709\u81f3\u5c11\u4e24\u4e2a\u5355\u8bcd\u76f8\u540c\u7684\u9879\u76ee\uff0c\u800c\u8be5\u9879\u76ee\u5219\u88ab\u89c6\u4e3a\u5e94\u7528\u7a0b\u5e8f\u7684\u5b89\u88c5\u76ee\u5f55\u3002\u5c06\u8fd9\u4e2a\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u5927\u5c0f\u6c47\u603b\u4e00\u4e0b\uff0c\u8fd9\u4e2a\u6570\u5b57\u5c31\u4f5c\u4e3a\u300eAwesome Program for Windows\u300f\u7684\u300e\u5927\u5c0f\u300f\u4e86\u3002<\/p>\n<p>A program can add some properties to its registration to avoid a lot of this guessing. It can set an EstimatedSize property to avoid making Add\/Remove Programs guess how big the program is. It can also set a DisplayIcon property to specify which icon to show for the program in the list.<\/p>\n<p>\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u5728\u5411\u6ce8\u518c\u8868\u4e2d\u5199\u5165\u4fe1\u606f\u65f6\u4e3b\u52a8\u6307\u5b9a\u5bf9\u5e94\u7684\u5c5e\u6027\u503c\u6765\u907f\u514d\u4e0a\u8ff0\u7684\u731c\u6d4b\u5de5\u4f5c\uff0c\u6bd4\u5982\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u00a0EstimatedSize \u5c5e\u6027\u6765\u7701\u53bb\u300e\u6dfb\u52a0\/\u5220\u9664\u7a0b\u5e8f\u300f\u4f30\u7b97\u5e94\u7528\u7a0b\u5e8f\u7684\u5927\u5c0f\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u00a0DisplayIcon \u6765\u6307\u5b9a\u5728\u5217\u8868\u4e2d\u5e94\u7528\u7a0b\u5e8f\u7684\u56fe\u6807\u3002<\/p>\n<p>But if a program omits all of these hints, the guess that Add\/Remove Programs ends up making can often be ridiculously wide of the mark due to coincidental word matches. In my experience, Spanish suffers particularly badly from this algorithm, due to that language\u2019s heavy use of prepositions and articles (which result in a lot of false matches).<\/p>\n<p>\u4e0d\u8fc7\uff0c\u5982\u679c\u67d0\u4e2a\u5e94\u7528\u7a0b\u5e8f\u5b8c\u5168\u65e0\u89c6\u8fd9\u4e9b\u63d0\u793a\u7684\u8bdd\uff0c\u300e\u6dfb\u52a0\/\u5220\u9664\u7a0b\u5e8f\u300f\u4f30\u6d4b\u51fa\u6765\u7684\u4fe1\u606f\u6709\u53ef\u80fd\u56e0\u4e3a\u5de7\u5408\u7684\u5355\u8bcd\u76f8\u7b26\u800c\u4e0e\u5b9e\u9645\u60c5\u51b5\u5927\u76f8\u5f84\u5ead\u3002\u636e\u6211\u4e2a\u4eba\u7ecf\u9a8c\u800c\u8a00\uff0c\u897f\u73ed\u7259\u8bed\uff08\u7684\u6761\u76ee\uff09\u5728\u9762\u5bf9\u8fd9\u4e00\u7b97\u6cd5\u65f6\u8bef\u5dee\u6700\u5927\uff0c\u539f\u56e0\u662f\u897f\u73ed\u7259\u8bed\u4e2d\u7684\u4ecb\u8bcd\u548c\u51a0\u8bcd\u7684\u4f7f\u7528\u6781\u5176\u9891\u7e41\uff08\u56e0\u800c\u9020\u6210\u4e86\u5927\u91cf\u7684\u8bef\u5339\u914d\uff09\u3002<\/p>\n<p>Yes, this is all lame, but when you are forced to operate with inadequate information, lame is the best you can do.<\/p>\n<p>\u6ca1\u9519\uff0c\u8fd9\u4e2a\u673a\u5236\u662f\u5f88\u8e69\u811a\uff0c\u4f46\u5f53\u4f60\u88ab\u8feb\u7528\u4e0d\u5b8c\u6574\u7684\u4fe1\u606f\u6765\u6784\u5efa\u8d44\u6599\u65f6\uff0c\u505a\u5230\u8e69\u811a\u5df2\u662f\u6700\u597d\u7684\u7ed3\u679c\u3002<\/p>\n<p>[July 15 2004: Emphasizing that this is done only if the program fails to provide the information itself. For some reason, a lot of people who link to this page fail to notice that little detail.]<\/p>\n<p>\uff082004\u5e747\u670815\u65e5\u66f4\u65b0\uff1a\u5f3a\u8c03\u4e00\u4e0b\uff0c\u300e\u6dfb\u52a0\/\u5220\u9664\u7a0b\u5e8f\u300f\u53ea\u6709\u5728\u5e94\u7528\u7a0b\u5e8f\u672a\u80fd\u63d0\u4f9b\u76f8\u5173\u4fe1\u606f\u65f6\u624d\u4f1a\u8fdb\u884c\u4e0a\u8ff0\u7684\u731c\u6d4b\u5de5\u4f5c\u3002\u4e0d\u77e5\u4e3a\u4f55\uff0c\u5f88\u591a\u94fe\u63a5\u5230\u8fd9\u4e2a\u9875\u9762\u7684\u8bfb\u8005\u90fd\u5ffd\u7565\u4e86\u8fd9\u4e00\u7ec6\u8282\u3002\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u6587\u94fe\u63a5\uff1ahttps:\/\/devblogs.microsoft.com\/oldnewthing\/2004070 [&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-2926","post","type-post","status-publish","format-standard","hentry","category-tont_history"],"_links":{"self":[{"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/posts\/2926","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=2926"}],"version-history":[{"count":0,"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/posts\/2926\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/media?parent=2926"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/categories?post=2926"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/tags?post=2926"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}