HI Members,
I have an issue with shell 32 system tray Icon in windows 10.
We have an application created in VB6, In which one of the module uses Shell32 dll to create , modify and delete system tray Icon.
Once System Tray Icon is created using Shell NM_ADD, We use shell NM_Modify call , during which a balloon notification with the message provided will displayed in the system tray.
When use the application in Windows 10 instead of balloon notification icon of windows 7 a new toast tray notification will come in windows 10.

My problem arises when I call shell Modify call in a loop:

I am calling Shell NM_modify in a loop of 100 count to show progress messages of 100 percent.
The same is working fine in windows 7 as classic balloon tray message. When I use the application in windows 10 the explorer restart is happening.
When I reduce the count Less than 20 the toast tray Icon in Windows 10 is working fine.
If I want to use same loop count 100 in windows 10, If we put sleep of 100 before shell modify of each call its working .

So there is some delay issue in Windows 10 toast tray due to which the explorer restart is happening.

Could anyone suggest any solution for This.
Currently I am going forward with two work around;
1. with sleep before NM modify call.
2. By reg edit setting in windows 10 to enable classic balloon system tray view.

Other than this any other solution can be provided.

My sample code is as below:

Option Explicit

Private Const NOTIFYICON_VERSION = 3

Private Const NOTIFYICONDATAA_V1_SIZE_A = 88
Private Const NOTIFYICONDATAA_V1_SIZE_U = 152
Private Const NOTIFYICONDATAA_V2_SIZE_A = 488
Private Const NOTIFYICONDATAA_V2_SIZE_U = 936

Private Enum NIM_CONSTANTS
NIM_ADD = &H0
NIM_MODIFY = &H1
NIM_DELETE = &H2
NIM_SETFOCUS = &H3
NIM_SETVERSION = &H4
End Enum

Private Enum NIF_CONSTANTS
NIF_MESSAGE = &H1
NIF_ICON = &H2
NIF_TIP = &H4
NIF_STATE = &H8
NIF_INFO = &H10
End Enum

Private Enum WM_CONSTANTS
WM_MOUSEMOVE = &H200
WM_LBUTTONDBLCLK = &H203
WM_LBUTTONDOWN = &H201
WM_LBUTTONUP = &H202
WM_RBUTTONDBLCLK = &H206
WM_RBUTTONDOWN = &H204
WM_RBUTTONUP = &H205
End Enum

Private Type NOTIFYICONDATA
cbSize As Long ' 4
hwnd As Long ' 8
uID As Long ' 12
uFlags As Long ' 16
uCallbackMessage As Long ' 20
hIcon As Long ' 24
szTip As String * 128 ' 152
dwState As Long ' 156
dwStateMask As Long ' 160
szInfo As String * 256 ' 416
uTimeOutOrVersion As Long ' 420
szInfoTitle As String * 64 ' 484
dwInfoFlags As Long ' 488
guidItem As Long ' 492
End Type

Private Const WM_USER = &H400
Private Const NIN_SELECT = WM_USER
Private Const NINF_KEY = &H1
Private Const NIN_KEYSELECT = (NIN_SELECT Or NINF_KEY)
Private Const NIN_BALLOONSHOW = (WM_USER + 2)
Private Const NIN_BALLOONHIDE = (WM_USER + 3)
Private Const NIN_BALLOONTIMEOUT = (WM_USER + 4)
Private Const NIN_BALLOONUSERCLICK = (WM_USER + 5)

Private Type POINTAPI
X As Long
Y As Long
End Type

Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As NIM_CONSTANTS, pnid As NOTIFYICONDATA) As Boolean
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function TrackPopupMenu Lib "user32" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal X As Long, ByVal Y As Long, ByVal nReserved As Long, ByVal hwnd As Long, ByVal lprc As Long) As Long

Dim IconData As NOTIFYICONDATA

Dim m_ToolTipText As String
Dim m_Visible As Boolean
Dim m_Show As Boolean
Dim m_SysMenu As Boolean

Event MouseMove()
Event MouseDown(Button As Integer)
Event MouseUp(Button As Integer)
Event DblClick(Button As Integer)
Event Click(Button As Integer)
Event SingleClick(Button As Integer)
Public Event BalloonShow()
Public Event BalloonHide()
Public Event BalloonTimeOut()
Public Event BalloonClicked()

Public Enum EBalloonIconTypes
NIIF_NONE = 0
NIIF_INFO = 1
NIIF_WARNING = 2
NIIF_ERROR = 3
NIIF_NOSOUND = &H10
End Enum

Private Sub Form_Load()
Dim i As Integer
Initialise
For i = 0 To 20 --> Here if loop exceeds more than 20 explorer restart in Windows 10.
Show_Balloon (i)
Next
End Sub

Public Sub Initialise()
IconData.hwnd = hwnd
IconData.uID = App.ThreadID
IconData.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
IconData.uCallbackMessage = WM_MOUSEMOVE
IconData.uTimeOutOrVersion = NOTIFYICON_VERSION
IconData.hIcon = Image1.Picture
IconData.cbSize = NOTIFYICONDATAA_V2_SIZE_A
Shell_NotifyIcon NIM_ADD, IconData
End Sub


Public Sub Show_Balloon(i As String)
Dim lR As Long
IconData.szInfo = "TEST" & i & vbNullChar
IconData.szInfoTitle = "TEST" & vbNullChar
IconData.uTimeOutOrVersion = 2000
IconData.dwInfoFlags = NIIF_INFO + NIIF_NOSOUND
IconData.uFlags = NIF_INFO
lR = Shell_NotifyIcon(NIM_MODIFY, IconData)
End Sub