TrayIcon - Symbole Verhalten - "Symbol und Benachrichtigungen anzeigen" automatisch?

  • VB.NET
  • .NET (FX) 4.0

Es gibt 2 Antworten in diesem Thema. Der letzte Beitrag () ist von Hinti.

    TrayIcon - Symbole Verhalten - "Symbol und Benachrichtigungen anzeigen" automatisch?

    Hallo,

    Ich möchte wenn mein Programm gestartet wird (es hat ein TrayIcon), dass dieses von mir automatisch die Option "Symbol und Benachrichtigungen anzeigen" erhält. Per Default macht Windows hier "Nur Benachrichtigungen". Siehe Bild (so würd ichs gern haben).

    Jetzt find ich dazu beim Googln einfach nix!
    Vielleicht kann mir wer einen Hinweis geben. Danke.
    Bilder
    • bild1.png

      24,82 kB, 434×233, 185 mal angesehen
    • bild2-will-haben.png

      2,62 kB, 303×72, 173 mal angesehen
    Soll scheinbar laut microsoft offiziell nicht unterstützt sein:
    msdn.microsoft.com/en-us/libra…ows/desktop/dn742495.aspx


    Windows 7 has gone a step further by focusing the notification on its original purpose of being a notification source. Most icons are hidden by default in Windows 7, but can be promoted to the notification area manually, by the user. To keep users in control of their desktops, there is no way[/b] for your program to perform this promotion automatically. Windows still displays notifications for hidden icons by promoting them temporarily.​


    Hab da aber was gefunden (ungetestet):

    VB.NET-Quellcode

    1. Imports System.Text
    2. Imports Microsoft.Win32
    3. Imports System.IO
    4. Public NotInheritable Class IconStreams
    5. Public Enum IconStreamVisibleValues As Integer
    6. OnlyShowNotifications = 0
    7. HideIconAndNotifications = 1
    8. ShowIconAndNotifications = 2
    9. End Enum
    10. Private Sub New()
    11. End Sub
    12. Private Shared Function ROT13(ByVal input As String) As String
    13. Dim sb As New StringBuilder
    14. For Each c As Char In input
    15. If Char.IsLetter(c) Then
    16. If Convert.ToInt32((Char.ToUpper(c))) < 78 Then
    17. sb.Append(Convert.ToChar(Convert.ToInt32(c) + 13))
    18. Else
    19. sb.Append(Convert.ToChar(Convert.ToInt32(c) - 13))
    20. End If
    21. Else
    22. sb.Append(c)
    23. End If
    24. Next
    25. Return sb.ToString
    26. End Function
    27. Public Shared Sub WriteIconStreamsVisibleValue(ByVal appExecutable As String, ByVal visibleValue As IconStreamVisibleValues)
    28. Dim iconStreamBytes() As Byte = Nothing
    29. Dim iconHeader() As Byte = Nothing
    30. Dim exeName() As Byte = Nothing
    31. Dim recordCount As Integer = 0
    32. ' Open registry key with write access permission.
    33. Dim r As RegistryKey = Registry.CurrentUser.OpenSubKey( _
    34. "Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify", True)
    35. ' We need the raw IconStream bytes read from registry.
    36. iconStreamBytes = r.GetValue("IconStreams", Nothing)
    37. Using ms As New MemoryStream(iconStreamBytes)
    38. Using reader As New BinaryReader(ms)
    39. ' Read the icon streams header, this also advances
    40. ' the position in the stream @20 offset.
    41. iconHeader = reader.ReadBytes(20)
    42. ' Read the IconStreams record count @12 byte offset
    43. ' in IconStreams header.
    44. recordCount = BitConverter.ToInt32(iconHeader, 12)
    45. ' Each IconStreams record after the 20 byte header
    46. ' is 1640 bytes.
    47. For i As Integer = 1 To recordCount
    48. ' Get the executable path information bytes.
    49. exeName = reader.ReadBytes(528)
    50. ' Advance 4 bytes in the stream for visibility position.
    51. reader.ReadInt32()
    52. ' The full executable path decoded using ROT13.
    53. If (ROT13(Encoding.Unicode.GetString(exeName))).Contains(appExecutable) Then
    54. ' Prepare to write the new visibility value into the stream.
    55. Using bw As New BinaryWriter(ms)
    56. ' The offset value in the stream to write.
    57. bw.Seek(reader.BaseStream.Position - 4, SeekOrigin.Begin)
    58. ' Write the new visible value.
    59. bw.Write(CInt(visibleValue))
    60. ' Save the new edited IconStreams bytes into the registry.
    61. r.SetValue("IconStreams", ms.ToArray)
    62. End Using
    63. Exit For '__leave
    64. End If
    65. ' Skip bytes
    66. reader.BaseStream.Seek(1108, SeekOrigin.Current)
    67. Next
    68. End Using
    69. End Using
    70. ' Close the registry handle
    71. r.Close()
    72. End Sub
    73. End Class