Imports System.Text Imports Microsoft.Win32 Imports System.IO Public NotInheritable Class IconStreams Public Enum IconStreamVisibleValues As Integer OnlyShowNotifications = 0 HideIconAndNotifications = 1 ShowIconAndNotifications = 2 End Enum Private Sub New() End Sub 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 Shared Sub WriteIconStreamsVisibleValue(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