Winforms 我能';我不能在启动时运行winform应用程序吗?

Winforms 我能';我不能在启动时运行winform应用程序吗?,winforms,Winforms,我补充说: RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); rkApp.SetValue("My Application", Application.ExecutablePath.ToString()); 但我的应用程序不会在启动时运行,我还设置: <requestedExecutionLevel level="r

我补充说:

RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
rkApp.SetValue("My Application", Application.ExecutablePath.ToString());
但我的应用程序不会在启动时运行,我还设置:

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

应用程序内清单

我的注册处:


请帮帮我

没有人回答这个问题有点奇怪

Application.ExecutablePath在某些情况下会返回不正确的结果,其中之一是“#”登录路径

改变

rkApp.SetValue("My Application", Application.ExecutablePath.ToString());


还记得更改所有剩余的路径(如果存在)。

为什么注册表中的路径有前后斜杠?我不知道:'v注册表值中的斜杠是错误的。您应该调试将此项添加到注册表的代码并修复斜杠
rkApp.SetValue("My Application", Application.StartupPath + @"\" + Process.GetCurrentProcess().ProcessName + ".exe");