Compartilhar via


SHNotificationAdd

Windows Mobile SupportedWindows Embedded CE Supported

9/9/2008

Essa função de forma assíncrona adiciona uma notificação a bandeja de notificação.

Observação

Em Windows Mobile 6 Standard é SHNotificationAdd não disponível.

Syntax

LRESULT SHNotificationAdd(
  SHNOTIFICATIONDATA* pndAdd
);

Parameters

  • pndAdd
    [no] Ponteiro para um SHNOTIFICATIONDATA estrutura descrevendo a notificação a ser adicionado.

Return Value

Para todas as plataformas

Essa função retorna ERROR_SUCCESS quando bem-sucedido.

Para Mobile Windows

A seguinte lista mostra os valores de retorno em falha, para Windows Mobile 6 Professional e Windows Mobile 6 Classic

  • ERROR_INVALID_PARAMETER
  • ERROR_OUTOFMEMORY
  • ERROR_DLL_INIT_FAILED
  • ERROR_NOT_FOUND
  • ERROR_NO_MATCH

A seguinte lista mostra os valores de retorno em falha, para Windows Mobile 6 Standard.

  • ERROR_INVALID_PARAMETER

Para obter uma descrição desses valores de erro, consulte Erros do SISTEMA - ordem alfabética.

Example

O seguinte exemplo de código demonstra como usar SHNotificationAdd.

Observação

Para fazer o seguinte exemplo de código mais fácil de ler, verificação de segurança e manipulação de erro não estão incluídos.Esta exemplo de código não deve ser usado em uma configuração versão a menos que ele foi modificado para incluí-las.

static const GUID CLSID_SHNAPI_Test = { 0x33765136, 0x8cb9, 0x449a, { 0xb0, 0x20, 0x43, 0xed, 0x40, 0xa, 0xb8, 0xfc } };
void SHNotificationExample()
{
    // This code will add an SHNotification notificaion 
    SHNOTIFICATIONDATA sn  = {0};
    SHNOTIFICATIONDATA sn2 = {0};
    sn.cbStruct = sizeof(sn);
    sn.dwID = 1;
    sn.npPriority = SHNP_INFORM;
    sn.csDuration = 15;
    sn.hicon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_SAMPLEICON));
    sn.clsid = CLSID_SHNAPI_Test;
    sn.grfFlags = 0;
    sn.pszTitle = TEXT("Sample Notification");
    sn.pszHTML = TEXT("<html><body>This is <b>sample html</b> in a notification!</body></html>");
    sn.rgskn[0].pszTitle = TEXT("Dismiss");
    sn.rgskn[0].skc.wpCmd = 100;
    //Add the notification to the tray

    //Put the data from an existing notification into a second SHNOTIFICATIONDATA struct
    sn2.cbStruct = sizeof(sn2);
    SHNotificationGetData(&CLSID_SHNAPI_Test, 1, &sn2);
    //Update the title, HTML, icon, and softkeys of the notification
    sn2.pszTitle = TEXT("Updated - Sample Notification");
    sn2.pszHTML = TEXT("<html><body>This notification has been <b>updated!</b></body></html>");
    sn2.hicon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_SAMPLEICON2));
    sn2.rgskn[0].pszTitle = TEXT("Disabled");
    sn2.rgskn[0].skc.wpCmd = 100;
    sn2.rgskn[0].skc.grfFlags = NOTIF_SOFTKEY_FLAGS_DISABLED;
    SHNotificationUpdate(SHNUM_TITLE | SHNUM_HTML | SHNUM_ICON | SHNUM_SOFTKEYCMDS | SHNUM_SOFTKEYS, &sn2);
    //Remove the notification from the tray
    SHNotificationRemove(&CLSID_SHNAPI_Test, 1);
    //Add a new notification that utilizes the MRE functionality
    sn.cbStruct = sizeof(sn);
    sn.dwID = 1;
    sn.npPriority = SHNP_INFORM;
    sn.csDuration = 15;
    sn.hicon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_SAMPLEICON));
    sn.clsid = CLSID_SHNAPI_Test;
    sn.grfFlags = SHNF_STRAIGHTTOTRAY;
    sn.pszTodaySK = TEXT("New Task");
    sn.pszTodayExec = TEXT("\\windows\\tasks.exe");
    //Add the notification to the tray
    SHNotificationAdd(&sn);
    //Remove the notification from the tray
    SHNotificationRemove(&CLSID_SHNAPI_Test, 1);
}

Remarks

Bandeja de notificação é a área dentro de barra de tarefas reservada pelo shells para exibir status notificação ícones. Chamar esta função para adicionar uma notificação para a bandeja. Processamento de notificação é feito de forma assíncrona; Ou seja, essa função retornará após adicionar a notificação a bandeja de, e processamento irá acontecer em um segmento diferente.

Requirements

Header aygshell.h
Library aygshell.lib
Windows Embedded CE Windows Embedded CE 6.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also

Reference

Shell Functions
SHNotificationRemove
SHNotificationUpdate
SHNotificationGetData
SHNOTIFICATIONDATA