如何在.net WPF应用程序中添加windows启动发送参数的应用程序?



我有一个使用Visual Studio开发的。net WPF桌面应用程序,我想将这个应用程序添加到windows启动中。Windows启动时应该发送参数"Start"因此,该程序将知道它是在登录后启动的,而不是用户。我已经看到了一些添加这个应用程序启动的解决方案,但找不到任何用参数启动应用程序的例子。示例代码片段:

Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
key.SetValue("Your Application Name", Application.ExecutablePath);

只是将值设置为Application.ExecutablePath,而不是附加参数本身。从我的注册表的例子:

Key:
MicrosoftEdgeAutoLaunch_AC4772F08F551843066B27D28EB56714
Value:
"C:Program Files (x86)MicrosoftEdgeApplicationmsedge.exe" --no-startup-window --win-session-start /prefetch:5

最新更新