{"id":692,"date":"2025-10-08T21:00:14","date_gmt":"2025-10-08T13:00:14","guid":{"rendered":"https:\/\/yuthk.com\/?p=692"},"modified":"2025-10-08T21:07:20","modified_gmt":"2025-10-08T13:07:20","slug":"c%e5%ae%9e%e7%8e%b0%e5%be%ae%e8%bd%af%e8%87%aa%e5%b8%a6regedit%e7%bc%96%e8%be%91%e5%99%a8%e6%89%93%e5%bc%80%e6%8c%87%e5%ae%9a%e6%b3%a8%e5%86%8c%e8%a1%a8%e8%b7%af%e5%be%84","status":"publish","type":"post","link":"https:\/\/yuthk.com\/?p=692","title":{"rendered":"C#\u5b9e\u73b0\u5fae\u8f6f\u81ea\u5e26regedit\u7f16\u8f91\u5668\u6253\u5f00\u6307\u5b9a\u6ce8\u518c\u8868\u8def\u5f84"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u539f\u7406<\/h2>\n\n\n\n<p>Windows\u6ce8\u518c\u8868\u7f16\u8f91\u5668(regedit.exe)\u6709\u4e00\u4e2a\u5185\u7f6e\u529f\u80fd\uff1a<strong>\u81ea\u52a8\u8bb0\u4f4f\u4e0a\u6b21\u5173\u95ed\u65f6\u6d4f\u89c8\u7684\u4f4d\u7f6e<\/strong>\u3002\u8fd9\u4e2a\u529f\u80fd\u662f\u901a\u8fc7\u5728\u6ce8\u518c\u8868\u4e2d\u5b58\u50a8&#8221;\u6700\u540e\u8bbf\u95ee\u7684\u8def\u5f84&#8221;\u6765\u5b9e\u73b0\u7684\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1.&nbsp;<strong>\u8bb0\u5fc6\u4f4d\u7f6e\u7684\u5b58\u50a8<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><em>\/\/ regedit\u5c06\u6700\u540e\u8bbf\u95ee\u7684\u8def\u5f84\u5b58\u50a8\u5728\u8fd9\u4e2a\u4f4d\u7f6e\uff1a<\/em>\nHKEY_CURRENT_USER\n\u2514\u2500\u2500 Software\n    \u2514\u2500\u2500 Microsoft\n        \u2514\u2500\u2500 Windows\n            \u2514\u2500\u2500 CurrentVersion\n                \u2514\u2500\u2500 Applets\n                    \u2514\u2500\u2500 Regedit\n                        \u2514\u2500\u2500 LastKey (REG_SZ) = \"\u76ee\u6807\u8def\u5f84\"<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2.&nbsp;<strong>\u5de5\u4f5c\u6d41\u7a0b<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">\u9884\u8bbe\u8def\u5f84 \u2192 \u542f\u52a8regedit \u2192 \u81ea\u52a8\u5bfc\u822a\n    \u2193           \u2193           \u2193\n\u8bbe\u7f6eLastKey \u2192 regedit\u542f\u52a8 \u2192 \u8bfb\u53d6LastKey \u2192 \u8df3\u8f6c\u5230\u6307\u5b9a\u4f4d\u7f6e<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3.&nbsp;<strong>\u8be6\u7ec6\u6267\u884c\u8fc7\u7a0b<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u6b65\u9aa41\uff1a\u9884\u8bbe\u76ee\u6807\u8def\u5f84<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\"><em>\/\/ \u5728\u542f\u52a8regedit\u4e4b\u524d\uff0c\u5148\u8bbe\u7f6e\u5b83\u7684\"\u8bb0\u5fc6\u4f4d\u7f6e\"<\/em>\nRegistry.SetValue(\n    @\"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit\", \n    \"LastKey\", \n    @\"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\"\n);<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u6b65\u9aa42\uff1a\u542f\u52a8\u6ce8\u518c\u8868\u7f16\u8f91\u5668<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">Process.Start(\"regedit.exe\");<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u6b65\u9aa43\uff1aregedit\u7684\u81ea\u52a8\u884c\u4e3a<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>regedit.exe\u542f\u52a8\u65f6\uff0c\u4f1a\u81ea\u52a8\u68c0\u67e5<code>LastKey<\/code>\u503c<\/li>\n\n\n\n<li>\u5982\u679c<code>LastKey<\/code>\u5b58\u5728\u4e14\u6709\u6548\uff0c\u76f4\u63a5\u5bfc\u822a\u5230\u8be5\u8def\u5f84<\/li>\n\n\n\n<li>\u5982\u679c<code>LastKey<\/code>\u4e0d\u5b58\u5728\u6216\u65e0\u6548\uff0c\u663e\u793a\u9ed8\u8ba4\u7684&#8221;\u6211\u7684\u7535\u8111&#8221;\u6839\u8282\u70b9<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u6e90\u7801<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\"><em>\/\/ 1. regedit.exe \u4f1a\u8bb0\u4f4f\u4e0a\u6b21\u6253\u5f00\u7684\u4f4d\u7f6e<\/em><br><em>\/\/ 2. \u8fd9\u4e2a\u4f4d\u7f6e\u5b58\u50a8\u5728\uff1aHKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit \u7684 LastKey \u503c\u4e2d<\/em><br><em>\/\/ 3. \u5148\u8bbe\u7f6e LastKey \u4e3a\u76ee\u6807\u8def\u5f84\uff0c\u518d\u542f\u52a8 regedit\uff0c\u5c31\u4f1a\u81ea\u52a8\u5b9a\u4f4d\u5230\u8be5\u8def\u5f84<\/em><br><br>string regeditMemoryKey = @\"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit\";<br>Registry.SetValue(regeditMemoryKey, \"LastKey\", registryPath); \/\/ \u9884\u8bbe\u8def\u5f84<br>Process.Start(\"regedit.exe\"); <em>\/\/ \u542f\u52a8\u6ce8\u518c\u8868\u7f16\u8f91\u5668<\/em><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u8be6\u7ec6\u793a\u4f8b<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>using System;\nusing System.Diagnostics;\nusing Microsoft.Win32;\n\n\/\/\/ &lt;summary&gt;\n\/\/\/ \u6ce8\u518c\u8868\u8def\u5f84\u6253\u5f00\u5de5\u5177\u7c7b\n\/\/\/ &lt;\/summary&gt;\npublic static class RegistryOpener\n{\n    \/\/\/ &lt;summary&gt;\n    \/\/\/ \u6253\u5f00\u6307\u5b9a\u6ce8\u518c\u8868\u8def\u5f84\n    \/\/\/ &lt;\/summary&gt;\n    \/\/\/ &lt;param name=\"registryPath\"&gt;\u5b8c\u6574\u7684\u6ce8\u518c\u8868\u8def\u5f84&lt;\/param&gt;\n    public static void OpenRegistryPath(string registryPath)\n    {\n        \/\/ \u8bbe\u7f6e\u6ce8\u518c\u8868\u7f16\u8f91\u5668\u7684\u8bb0\u5fc6\u4f4d\u7f6e\n        string regeditMemoryKey = @\"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit\";\n        Registry.SetValue(regeditMemoryKey, \"LastKey\", registryPath);\n        \n        \/\/ \u542f\u52a8\u6ce8\u518c\u8868\u7f16\u8f91\u5668\uff0c\u4f1a\u81ea\u52a8\u5b9a\u4f4d\u5230\u9884\u8bbe\u8def\u5f84\n        Process.Start(\"regedit.exe\");\n    }\n}\n\n\/\/ \u4f7f\u7528\u793a\u4f8b\npublic class Example\n{\n    public void Demo()\n    {\n        \/\/ \u6253\u5f00\u7a0b\u5e8f\u5378\u8f7d\u4fe1\u606f\n        string path = @\"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam\";\n        RegistryOpener.OpenRegistryPath(path);\n    }\n}<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u7406 Windows\u6ce8\u518c\u8868\u7f16\u8f91\u5668(regedit.exe)\u6709\u4e00\u4e2a\u5185\u7f6e\u529f\u80fd\uff1a\u81ea\u52a8\u8bb0\u4f4f\u4e0a\u6b21\u5173\u95ed\u65f6\u6d4f\u89c8\u7684\u4f4d\u7f6e\u3002\u8fd9\u4e2a\u529f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26,25,4,5],"tags":[],"class_list":["post-692","post","type-post","status-publish","format-standard","hentry","category-net","category-c","category-4","category-5"],"_links":{"self":[{"href":"https:\/\/yuthk.com\/index.php?rest_route=\/wp\/v2\/posts\/692","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yuthk.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yuthk.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yuthk.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yuthk.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=692"}],"version-history":[{"count":8,"href":"https:\/\/yuthk.com\/index.php?rest_route=\/wp\/v2\/posts\/692\/revisions"}],"predecessor-version":[{"id":700,"href":"https:\/\/yuthk.com\/index.php?rest_route=\/wp\/v2\/posts\/692\/revisions\/700"}],"wp:attachment":[{"href":"https:\/\/yuthk.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=692"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yuthk.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=692"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yuthk.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=692"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}