{"id":483,"date":"2015-05-12T14:01:48","date_gmt":"2015-05-12T06:01:48","guid":{"rendered":"http:\/\/www.withonly.com\/?p=483"},"modified":"2018-08-13T10:21:04","modified_gmt":"2018-08-13T02:21:04","slug":"win788-1%e4%b8%adc%e9%99%84%e5%8a%a0%e7%a8%8b%e5%ba%8f%e5%88%b0%e4%bb%bb%e5%8a%a1%e6%a0%8f","status":"publish","type":"post","link":"https:\/\/blog.5danyuan.com\/?p=483","title":{"rendered":"win7\/8\/8.1\u4e2dc#\u9644\u52a0\u7a0b\u5e8f\u5230\u4efb\u52a1\u680f"},"content":{"rendered":"<p>\u8fdc\u7684\u4e0d\u8bf4\uff0c\u81ea\u4ecewin7\u5f00\u59cb\uff0c\u5f53\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u88ab\u9644\u52a0\u5230\u4efb\u52a1\u680f\u540e\uff0c\u4efb\u52a1\u680f\u5c31\u6210\u4e3a\u5404\u4e2a\u5e94\u7528\u62a2\u5360\u7684\u5165\u53e3\uff0c\u8fd9\u91cc\u53ef\u4ee5\u6bd4\u5f00\u59cb\u83dc\u5355\u66f4\u5feb\u5730\u542f\u52a8\u7a0b\u5e8f\u3002\u540e\u6765\u542c\u8bf4\u5fae\u8f6f\u5bf9OEM\u5382\u5546\u6709\u8981\u6c42\uff0c\u9884\u88c5\u8f6f\u4ef6\u4e0d\u80fd\u968f\u4fbfpin\u5230\u4efb\u52a1\u680f\u4e0a\uff0c\u54c8\u54c8\u3002<\/p>\n<p>\u4eca\u5929\u8863\u670d\u81ea\u5df1\u6d17\u5c31\u6765\u5206\u4eab\u5982\u4f55\u9644\u52a0\u7a0b\u5e8f\u5230\u4efb\u52a1\u680f\u4e0a\u3002<\/p>\n<p>\u5927\u81f4\u7684\u6d41\u7a0b\u662f\u5148\u521b\u5efa\u4e00\u4e2a\u5feb\u6377\u65b9\u5f0f\uff0c\u7136\u540e\u5bf9\u8be5\u5feb\u6377\u65b9\u5f0f\u6267\u884c\u9644\u52a0\u547d\u4ee4\u3002\u9644\u52a0\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u5220\u9664\u8be5\u5feb\u6377\u65b9\u5f0f\uff0c\u4efb\u52a1\u680f\u56fe\u6807\u8fd8\u662f\u5b58\u5728\u7684\u3002\u5bf9\u4e8e\u53d6\u6d88\u662f\u4e00\u6837\u7684\u6b65\u9aa4\uff0c\u65e0\u975e\u5c31\u662f\u6b65\u9aa4\u4e0d\u4e00\u6837\u800c\u5df2\u3002\u5f53\u9644\u52a0\u6210\u529f\u540e\uff0c\u4f1a\u5728\u7528\u6237\u7684Roaming\u76f8\u5173\u76ee\u5f55\u4e0b\u81ea\u52a8\u751f\u6210\u5feb\u6377\u65b9\u5f0f\uff0c\u7cfb\u7edf\u4f1a\u4f7f\u7528\u8be5\u5feb\u6377\u65b9\u5f0f\uff0c\u800c\u4e0d\u662f\u524d\u9762\u521b\u5efa\u7684\u5feb\u6377\u65b9\u5f0f\u3002<\/p>\n<p>\u547d\u4ee4\u5c31\u662f\u52a8\u4f5c\u8c13\u8bcd\uff0c\u5e38\u89c1\u7684\u8c13\u8bcd\u6709run\u3001open\u7b49\u64cd\u4f5c\uff0c\u800c\u9644\u52a0\u548c\u53d6\u6d88\u7684\u8c13\u8bcd\u5c31\u662fTaskbarPin\/TaskbarUnPin\uff0c\u4ece\u5b9e\u9645\u7ecf\u9a8c\u6765\u770b\uff0c\u8c13\u8bcd\u662f\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u7684\u3002\u4ee3\u7801\u5f88\u7b80\u5355\uff0c\u770b\u770b\u5c31\u660e\u767d\u4e86\u3002<br \/>\n\u5148\u7533\u660e\u64cd\u4f5c\u7684\u8fd4\u56de\u503c\u679a\u4e3e<\/p>\n<blockquote><p>public enum FileResult<br \/>\n{<br \/>\nSuccess,Failed,Exist,NotExist<br \/>\n}<\/p><\/blockquote>\n<p>\u9644\u52a0\u5230\u4efb\u52a1\u680f<\/p>\n<blockquote><p>public static FileResult PinToTaskBar(string linkPath, bool deleteLink = false)<br \/>\n{<br \/>\nif (!File.Exists(linkPath))<br \/>\n{<br \/>\n\/\/ \u5feb\u6377\u65b9\u5f0f\u4e0d\u5b58\u5728<br \/>\nreturn FileResult.Failed;<br \/>\n}<\/p>\n<p>string name = System.IO.Path.GetFileName(linkPath);<br \/>\nstring userPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile, Environment.SpecialFolderOption.None)<br \/>\n+&#8221;\\\\AppData\\\\Roaming\\\\Microsoft\\\\Internet Explorer\\\\Quick Launch\\\\User Pinned\\\\TaskBar\\\\&#8221;;<\/p>\n<p>if (File.Exists(userPath + name))<br \/>\n{<br \/>\n\/\/\u5f53pin\u5230\u4efb\u52a1\u680f\u540e\uff0c\u8be5\u76ee\u5f55\u4e0b\u4f1a\u751f\u6210\u5bf9\u5e94\u7684\u5feb\u6377\u65b9\u5f0f\u3002<br \/>\n\/\/\u901a\u8fc7\u5224\u65ad\u8be5\u6587\u4ef6\u662f\u5426\u5b58\u5728\u5224\u65ad\u662f\u5426\u5df2\u7ecfpin\u5230\u4efb\u52a1\u680f<br \/>\nreturn FileResult.Exist;<br \/>\n}<\/p>\n<p>ProcessStartInfo psi = new ProcessStartInfo(linkPath);<\/p>\n<p>psi.Verb = &#8220;TaskbarPin&#8221;;<br \/>\nProcess.Start(psi);<\/p>\n<p>if (deleteLink)<br \/>\n{<br \/>\n\/\/pin \u5b8c\u540e\u5220\u9664\u5feb\u6377\u65b9\u5f0f<br \/>\nFile.Delete(linkPath);<br \/>\n}<\/p>\n<p>return FileResult.Success;<br \/>\n}<\/p><\/blockquote>\n<p>\u53d6\u6d88\u9644\u52a0\u5230\u4efb\u52a1\u680f<\/p>\n<blockquote><p>public static FileResult UnPinToTaskBar(string linkPath, bool deleteLink = false)<br \/>\n{<br \/>\nif (!File.Exists(linkPath))<br \/>\n{<br \/>\n\/\/ \u5feb\u6377\u65b9\u5f0f\u4e0d\u5b58\u5728<br \/>\nreturn FileResult.Failed;<br \/>\n}<\/p>\n<p>string name = System.IO.Path.GetFileName(linkPath);<br \/>\nstring userPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile, Environment.SpecialFolderOption.None)<br \/>\n+ &#8220;\\\\AppData\\\\Roaming\\\\Microsoft\\\\Internet Explorer\\\\Quick Launch\\\\User Pinned\\\\TaskBar\\\\&#8221;;<\/p>\n<p>if (!File.Exists(userPath + name))<br \/>\n{<br \/>\n\/\/\u5f53pin\u5230\u4efb\u52a1\u680f\u540e\uff0c\u8be5\u76ee\u5f55\u4e0b\u4f1a\u751f\u6210\u5bf9\u5e94\u7684\u5feb\u6377\u65b9\u5f0f\u3002<br \/>\n\/\/\u901a\u8fc7\u5224\u65ad\u8be5\u6587\u4ef6\u662f\u5426\u5b58\u5728\u5224\u65ad\u662f\u5426\u5df2\u7ecfpin\u5230\u4efb\u52a1\u680f<br \/>\nreturn FileResult.NotExist;<br \/>\n}<\/p>\n<p>ProcessStartInfo psi = new ProcessStartInfo(linkPath);<\/p>\n<p>psi.Verb = &#8220;TaskbarUnPin&#8221;;<br \/>\nProcess.Start(psi);<\/p>\n<p>if (deleteLink)<br \/>\n{<br \/>\n\/\/pin \u5b8c\u540e\u5220\u9664\u5feb\u6377\u65b9\u5f0f<br \/>\nFile.Delete(linkPath);<br \/>\n}<\/p>\n<p>return FileResult.Success;<br \/>\n}<\/p><\/blockquote>\n<p>\u5b8c\u6574\u7684\u4ee3\u7801\u5982\u4e0b\u56fe\u6240\u793a\u3002<\/p>\n<p><a href=\"\/wp-content\/uploads\/2015\/05\/pin2TaskBar.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-535\" src=\"\/wp-content\/uploads\/2015\/05\/pin2TaskBar.png\" alt=\"pin2TaskBar\" width=\"821\" height=\"1978\" srcset=\"https:\/\/blog.5danyuan.com\/wp-content\/uploads\/2015\/05\/pin2TaskBar.png 821w, https:\/\/blog.5danyuan.com\/wp-content\/uploads\/2015\/05\/pin2TaskBar-125x300.png 125w, https:\/\/blog.5danyuan.com\/wp-content\/uploads\/2015\/05\/pin2TaskBar-425x1024.png 425w\" sizes=\"auto, (max-width: 821px) 100vw, 821px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>\u5728\u6267\u884c\u9644\u52a0\u64cd\u4f5c\u7684\u65f6\u5019\uff0c\u5982\u679c\u4efb\u52a1\u680f\u4e0a\u5df2\u7ecf\u9644\u52a0\u4e86\uff0c\u6267\u884c\u8c13\u8bcd\u547d\u4ee4\u5c31\u4f1a\u5931\u8d25\u3002\u540c\u7406\uff0c\u5982\u679c\u4efb\u52a1\u680f\u4e0a\u6ca1\u6709\uff0c\u6267\u884c\u53d6\u6d88\u9644\u52a0\u4e5f\u4f1a\u5931\u8d25\uff0c\u6240\u4ee5\u5c31\u9700\u8981\u505a\u4e00\u4e2a\u5224\u65ad\uff0c\u53ea\u5728\u5fc5\u8981\u7684\u65f6\u5019\u6765\u505a\u5224\u65ad\u3002\u5e76\u6839\u636e\u4e0d\u540c\u7684\u60c5\u51b5\u8fd4\u56de\u4e0d\u540c\u7684\u679a\u4e3e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fdc\u7684\u4e0d\u8bf4\uff0c\u81ea\u4ecewin7\u5f00\u59cb\uff0c\u5f53\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u88ab\u9644\u52a0\u5230\u4efb\u52a1\u680f\u540e\uff0c\u4efb\u52a1\u680f\u5c31\u6210\u4e3a\u5404\u4e2a\u5e94\u7528\u62a2\u5360\u7684\u5165\u53e3\uff0c\u8fd9\u91cc\u53ef\u4ee5\u6bd4\u5f00\u59cb\u83dc\u5355 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[120,52,238],"class_list":["post-483","post","type-post","status-publish","format-standard","hentry","category-daily","tag-c-sharp","tag-52","tag-238"],"_links":{"self":[{"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=\/wp\/v2\/posts\/483","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=483"}],"version-history":[{"count":0,"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=\/wp\/v2\/posts\/483\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}