Shell_NotifyIcon
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_NotifyIcon will disappear after the calling process exits. For an icon to survive beyond the timeframe of the calling process, it should be created through SHNotificationAdd.
WINSHELLAPI BOOL WINAPI Shell_NotifyIcon(
DWORD dwMessage,
PNOTIFYICONDATA pnid
);
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 NOTIFYICONDATA structure. The content of the structure depends on the value of dwMessage.
Nonzero indicates success. Zero indicates failure.
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.
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;
}
Header | shellapi.h |
Windows Embedded CE | Windows CE 1.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |