Windows notificaction area icons after update

Zexor

Well-known member
Joined
Nov 28, 2008
Messages
520
Programming Experience
3-5
Every time i publish a new version and the software updates it. There would be a new entry at the windows notification area settings. So if i want the icon to always show, i have to set it every time i publish. I see other programs even after updates they know its the same program and the setting stays. How can this be done?
 
The API structure NOTIFYICONDATA has a new member guidItem that is only used since Windows 7. Windows will preserve notification icon settings when this is set and has same value as previous version. The .Net NotifyIcon class does not include this functionality.
 
so are you saying it can't be done with NotifyIcon? Then what other way to do it so the icon settings stays after update?
 
That is correct. You can use the native notification area API instead of NotifyIcon component if you're using Windows 7, before that it is not possible, at least not officially.
 
By adding the necessary declarations and making the appropriate calls. This is not something for the inexperienced, the only clue the advanced programmer should need is 'NOTIFYICONDATA' that I mentioned in post 2.
 
can i define it like this?
VB.NET:
    <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
    Structure NOTIFYICONDATA
        Dim cbSize As Integer
        Dim hWnd As IntPtr
        Dim uID As Integer
        Dim uFlags As Integer
        Dim uCallbackMessage As Integer
        Dim hIcon As IntPtr
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)> Dim szTip As String
        Dim dwState As Integer
        Dim dwStateMask As Integer
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Dim szInfo As String
        Dim uTimeout As Integer ' ignore the uVersion union
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=64)> Dim szInfoTitle As String
        Dim dwInfoFlags As Integer
        Dim guidItem As Guid
    End Structure
 
NotifyIcon and Windows 7 notifications setting

Is there an easy way to keep the windows 7 notifications setting for showing the icon for my app after an update? Or do i have to use API and play with Notifyicondata? If so, can someone show me how to do it?
 
Back
Top