nid.cbSize = sizeof(NOTIFYICONDATA); nid.hwnd = hWnd; // Handle to the window that owns the icon nid.uID = 1; // Identifier of the icon

The guidItem field is optional. For icons added with NOTIFYICONIDENTIFIER_FLAGS.NIIF_USER or similar, you may need it. For classic NIM_ADD via NOTIFYICONDATA , set guidItem = Guid.Empty .

[StructLayout(LayoutKind.Sequential)] struct NOTIFYICONIDENTIFIER

#include <windows.h> #include <shellapi.h> #include <iostream> #include <string>

[DllImport("shell32.dll", CharSet = CharSet.Unicode, PreserveSig = false)] static extern void Shell_NotifyIconGetRect(ref NOTIFYICONIDENTIFIER identifier, out RECT iconRect);

#include <shellapi.h>