Wpf应用程序隐藏在Windows启动时

编程入门 行业动态 更新时间:2024-10-24 14:19:52
本文介绍了Wpf应用程序隐藏在Windows启动时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

目前我的应用程序正在Windows启动时启动。 必填: 我想要在Windows启动时隐藏应用程序,当我点击桌面快捷方式它应该启动。 或 我希望应用程序在Windows启动时的系统托盘中,当我点击桌面快捷方式或点击它应该启动的系统托盘图标。 我尝试过: 使用此代码,我可以在Windows启动时启动我的应用程序,但无法隐藏请帮助。 使用(RegistryKey key = Registry。 CurrentUser.OpenSubKey(SOFTWARE \\ Microsoft \\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ SetValue(myApplication,\+ System.Reflection.Assembly.GetExecutingAssembly()。Location +\); }

解决方案 FORMA lly,这个问题毫无意义,因为在应用程序启动时你没有任何WPF应用程序。所以,没有什么可隐瞒的。如果你不想让它运行,不要启动它。 然而,从本质上讲,它具有完美的感觉。但是,首先,你不必隐藏任何东西。最好的情况是,您可以创建一个Web应用程序,该应用程序在某些事件之前不会显示其UI(不会调用 Application.Run )。但是你关于点击桌面的第一个想法还不够好,所以如果你不介意的话,我不会讨论它。 你的第二个想法,关于系统托盘,要好得多。实际上,它非常好。如果它是 System.Windows.Forms.Application ,那很简单,因为这个库有类 System.Windows.Forms.NotifyIcon 用于此类目的。 对于WPF,请参阅: WPF NotifyIcon扩展 [ ^ ], www.nuget/packages/Hardcodet.NotifyIcon.Wpf [ ^ ]。 这个非常受欢迎的CodeProject文章也很有用: www.codeproject/Articles/36468/WPF-NotifyIcon [ ^ ]。
-SA

Currently my application is getting launch on windows start up. Required: I want to HIDE the application on windows startup and when i click on desktop shortcut it should launch. Or I want the application to be in system tray on windows startup and when i click on desktop shortcut or click on system tray icon it should launch. What I have tried: Using this code i can able to launch my application on windows startup but cannot hide please help. using (RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true)) { key.SetValue("myApplication", "\"" + System.Reflection.Assembly.GetExecutingAssembly().Location + "\""); }

解决方案

Formally, the question makes no sense, because on application start you don't have any WPF applications. So, there is nothing to hide. If you don't want it to run, don't start it. However, in essence, it has perfect sense. But, to start with, you don't have to hide anything. At best, you can create a Web application which does not show its UI (doesn't call Application.Run) until certain event. But your first idea, about clicking on the desktop, is not good enough, so I would not discuss it, if you don't mind. Your second idea, about the system tray, is much better. Actually, it's quite good. If it was a System.Windows.Forms.Application, it would be simple, because this library has the class System.Windows.Forms.NotifyIcon for such purposes. For WPF, please see: WPF NotifyIcon extension[^], www.nuget/packages/Hardcodet.NotifyIcon.Wpf[^]. This very popular CodeProject article can also be useful: www.codeproject/Articles/36468/WPF-NotifyIcon[^].
—SA

更多推荐

Wpf应用程序隐藏在Windows启动时

本文发布于:2023-11-05 08:30:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1560371.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:启动时   应用程序   Wpf   Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!