Shell_NotifyIcon Function

Adds, modifies, or deletes an icon in the specified notification area.

Syntax


BOOL Shell_NotifyIcon(
  DWORD  dwMessage,
  PNOTIFYICONDATA  pnid
);
            

Parameters

  • dwMessage: [in] A value that specifies the action to be performed. This parameter can be one of the following values:
    • NIM_ADD: Add an icon to the notification area.
    • NIM_MODIFY: Modify an existing icon in the notification area.
    • NIM_DELETE: Delete an icon from the notification area.
    • NIM_SETFOCUS: (Windows Vista and later) Sets the focus to the notification area.
    • NIM_IMPLICIT_UPGRADE: (Windows 7 and later) Indicates that the notification icon has been implicitly upgraded to a notification in the Action Center.
  • pnid: [in, out] A pointer to a NOTIFYICONDATA structure that contains information about the icon and the callback information.

Return Value

Returns TRUE if successful, or FALSE otherwise.

Remarks

  • The NOTIFYICONDATA structure must be fully initialized before being passed to this function.
  • The cbSize member of the NOTIFYICONDATA structure must be set to the size of the structure in bytes.
  • The uID member of the NOTIFYICONDATA structure specifies a unique identifier for the icon.
  • The uFlags member of the NOTIFYICONDATA structure specifies which members of the structure are valid.
  • When using NIM_ADD or NIM_MODIFY, the hIcon member of the NOTIFYICONDATA structure must contain a handle to the icon to be displayed.
  • When using NIM_DELETE, only the cbSize, hWnd, and uID members of the NOTIFYICONDATA structure need to be valid.

NOTIFYICONDATA Structure

Contains information used by the notification area to display and manage notification icons.


typedef struct tagNOTIFYICONDATA {
  DWORD  cbSize;
  HWND   hWnd;
  UINT   uID;
  UINT   uFlags;
  UINT   uCallbackMessage;
  HICON  hIcon;
  TCHAR  szTip[128];
  DWORD  dwState;
  DWORD  dwStateMask;
  TCHAR  szInfo[256];
  UINT   uTimeout;
  TCHAR  szInfoTitle[64];
  DWORD  dwInfoFlags;
  GUID   guidItem;
  HICON  hBalloonIcon;
} NOTIFYICONDATA, *LPNOTIFYICONDATA;