如何在托盘中保留notifyIcon。它消失在系统托盘的向上箭头区域 [英] How do I keep a notifyIcon in tray. It dissapears into the up arrow area of the system tray
本文介绍了如何在托盘中保留notifyIcon。它消失在系统托盘的向上箭头区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我制作了一个最小化系统托盘的程序。但它不会留在那里。它会消失在任务栏的向上箭头区域。我知道它可以做到,因为其他应用程序没有这个问题(比如AVG)。
那么......诀窍是什么?
I've made a program that minimizes to the system tray. But it won't stay there. It disappears into the "up arrow" area of the taskbar. I know it can be done, because other applications don't have this problem (such as AVG).
So... what's the trick?
推荐答案
阅读此 [ ^ ],认为它可能有你想要的答案。
Read this[^], think it may have the answer you seek.
感谢您的链接。其中一些我已经看过,但有些不是。与此同时,我发现了一些应该解决问题的代码。然而,我得到了着名的这样的事情并没有宣布也许不是...... yada,yada。也许有人可以告诉我为什么会发生这种情况?
Thanks for the link. Some of them I've already seen, but some not. In the meantime, I found some code that is "supposed" to get around the issue. However, I'm getting the famous "such and such is not declared and may not be... yada, yada. Maybe someone can tell me why this is happening to me?
Private Shared Function ROT13(ByVal input As String) As String
Dim sb As New StringBuilder
For Each c As Char In input
If Char.IsLetter(c) Then
If Convert.ToInt32((Char.ToUpper(c))) < 78 Then
sb.Append(Convert.ToChar(Convert.ToInt32(c) + 13))
Else
sb.Append(Convert.ToChar(Convert.ToInt32(c) - 13))
End If
Else
sb.Append(c)
End If
Next
Return sb.ToString
End Function
Public Sub writeToRegStream(ByVal appExecutable As String, ByVal visibleValue As IconStreamVisibleValues)
Dim iconStreamBytes() As Byte = Nothing
Dim iconHeader() As Byte = Nothing
Dim exeName() As Byte = Nothing
Dim recordCount As Integer = 0
' Open registry key with write access permission.
Dim r As RegistryKey = Registry.CurrentUser.OpenSubKey(
"Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify", True)
' We need the raw IconStream bytes read from registry.
iconStreamBytes = r.GetValue("IconStreams", Nothing)
Using ms As New MemoryStream(iconStreamBytes)
Using reader As New BinaryReader(ms)
' Read the icon streams header, this also advances
' the position in the stream @20 offset.
iconHeader = reader.ReadBytes(20)
' Read the IconStreams record count @12 byte offset
' in IconStreams header.
recordCount = BitConverter.ToInt32(iconHeader, 12)
' Each IconStreams record after the 20 byte header
' is 1640 bytes.
For i As Integer = 1 To recordCount
' Get the executable path information bytes.
exeName = reader.ReadBytes(528)
' Advance 4 bytes in the stream for visibility position.
reader.ReadInt32()
' The full executable path decoded using ROT13.
If (ROT13(Encoding.Unicode.GetString(exeName))).Contains(appExecutable) Then
' Prepare to write the new visibility value into the stream.
Using bw As New BinaryWriter(ms)
' The offset value in the stream to write.
bw.Seek(reader.BaseStream.Position - 4, SeekOrigin.Begin)
' Write the new visible value.
bw.Write(CInt(visibleValue))
' Save the new edited IconStreams bytes into the registry.
r.SetValue("IconStreams", ms.ToArray)
End Using
Exit For '__leave
End If
' Skip bytes
reader.BaseStream.Seek(1108, SeekOrigin.Current)
Next
End Using
End Using
' Close the registry handle
r.Close()
End Sub
End Class
这是writeToRegStream子,让我心疼。另外,你能告诉我这是否有用吗?我现在真的不确定。
再次感谢大家。
It's the "writeToRegStream" sub that is giving me heartache. Also, can you tell if this will work or not? I'm really not sure at this point.
Thanks again everyone.
这篇关于如何在托盘中保留notifyIcon。它消失在系统托盘的向上箭头区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文