Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function sends a message to the system to add, modify, or delete an application-specific icon from the taskbar status area. It does not affect icons appearing on the home screen.

Note:
Icons created using Shell_NotifyIconwill disappear after the calling process exits. For an icon to survive beyond the timeframe of the calling process, it should be created through SHNotificationAdd.

Syntax

WINSHELLAPI BOOL WINAPI Shell_NotifyIcon(
  DWORD 
dwMessage, 
  PNOTIFYICONDATA 
pnid 
);

Parameters

dwMessage

[in] Specifies the message value to send. The following table shows the possible values.

Value Description

NIM_ADD

Adds an icon to the status area.

NIM_DELETE

Deletes an icon from the status area.

NIM_MODIFY

Modifies an icon in the status area.

pnid

[in] Pointer to a NOTIFYICONDATAstructure. The content of the structure depends on the value of dwMessage.

Return Value

Nonzero indicates success. Zero indicates failure.

Code Example

The following code example demonstrates how to use Shell_NotifyIcon.

Note:
To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it has been modified to include them.
Copy Code
void Shell_NotifyIconExample()
{
	// Add a Shell_NotifyIcon notificaion
	NOTIFYICONDATA nid = {0};
	nid.cbSize		 = sizeof(nid);
	nid.uID			= 100; // Per Windows Embedded CE docs,
values from 0 to 12 are reserved and should not be used.
	nid.uFlags		 = NIF_ICON;
	nid.hIcon		= LoadIcon(g_hInstance,
MAKEINTRESOURCE(IDI_SAMPLEICON));
	// Add the notification to the tray.
	Shell_NotifyIcon(NIM_ADD, &nid);
	// Update the notification icon.
	nid.uFlags		 = NIF_ICON;
	nid.hIcon		= LoadIcon(g_hInstance,
MAKEINTRESOURCE(IDI_SAMPLEICON2));
	Shell_NotifyIcon(NIM_MODIFY, &nid);
	// Remove the notification from the tray.
	Shell_NotifyIcon(NIM_DELETE, &nid);
	return;
}

Requirements

Header shellapi.h
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also