WPF - 删除应用程序启动后自动运行

use*_*206 1 .net c# wpf

所以我使用此代码添加Key registry 以在启动时自动打开我的应用程序:

Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
Assembly curAssembly = Assembly.GetExecutingAssembly();
key.SetValue(curAssembly.GetName().Name, curAssembly.Location);
Run Code Online (Sandbox Code Playgroud)

所以现在我希望能够删除此选项,以便将其添加到应用程序用户定义中,以便我搜索RemoveKey类似的内容。

有什么建议 ?

Gre*_*rko 5

使用DeleteValue()方法:

key.DeleteValue(curAssembly.GetName().Name);
Run Code Online (Sandbox Code Playgroud)