我开发了一个WPF应用程序,现在我需要将该应用程序在Windows启动时启动。
为此,我编写了以下代码。 我从这个答案中获得了解决方案。
它能够向注册表中添加键但无法启动应用程序。
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
string str = Assembly.GetExecutingAssembly().Location;
key.SetValue("Camaleone", str);