gpt4 book ai didi

vb.net - 在 Windows 启动时运行没有窗体的程序

转载 作者:行者123 更新时间:2023-12-02 00:11:32 26 4
gpt4 key购买 nike

我基本上想要展示的是:

notifyicon.visible = true

我的意思是在Windows启动时显示托盘图标,但不应该显示程序窗体,我该如何实现?

我知道通过添加到注册表,您可以在下面的启动示例中运行该程序

Dim regkey As RegistryKey
regkey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", True)
If (runonstartupToolStripMenuItem.Checked = True) Then
' Add the value in the registry so that the application runs at startup
regkey.SetValue("Your Application Name", Application.ExecutablePath.ToString())
Else
' Remove the value from the registry so that the application doesn't start
regkey.DeleteValue("Your Application Name", False)
End If

但这将运行整个程序,并且会显示我不想要的表单,除非用户手动启动它。

最佳答案

将此代码添加到您的表单中:

 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Hide() ' <= Required
Me.ShowInTaskbar = False ' <= Required
NotifyIcon1.Visible = True
NotifyIcon1.ShowBalloonTip(10000)
End Sub

当程序在 Windows 启动时打开时,它应该使用唯一的参数打开,当找到唯一参数时,表单将被隐藏,反之,如果用户打开程序,则不会有参数,然后表单就可以显示。

关于vb.net - 在 Windows 启动时运行没有窗体的程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46556097/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com