我开发了一个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);
Run Code Online (Sandbox Code Playgroud)