I put together the following OutputNotifications() function to show how to enumerate User Notifications.
#include <Notify.h>
void OutputNotifications()
{
HANDLE *hNotifications = NULL;
DWORD NumNotifications;
DWORD Count;
DWORD BytesNeeded;
CE_NOTIFICATION_INFO_HEADER *NIHeader;
CE_NOTIFICATION_TRIGGER* Trigger;
CE_USER_NOTIFICATION* UserNotification;
void *pBuffer;
// First call CeGetUserNotifications to find out how many notifications are available
// by passing in zero as the second argument
CeGetUserNotificationHandles( hNotifications, 0, &NumNotifications );
RETAILMSG( 1, (TEXT("Num Notifications available %d\n"), NumNotifications ));
hNotifications = (HANDLE *)malloc( NumNotifications * sizeof( HANDLE *) );
// Now get the notifications
CeGetUserNotificationHandles( hNotifications, NumNotifications, &NumNotifications );
for( Count = 0; Count < NumNotifications; Count++ )
{
// Now with a valid handle to a notification find out how many bytes are needed
// to get the data
CeGetUserNotification( hNotifications[Count], 0, &BytesNeeded, NULL );
RETAILMSG( 1, (TEXT("%d Bytes needed %d\n"), Count, BytesNeeded ));
pBuffer = malloc( BytesNeeded );
// Error checking left for you, but now we can get the data
CeGetUserNotification( hNotifications[Count], BytesNeeded, &BytesNeeded, (BYTE *)pBuffer );
NIHeader = (CE_NOTIFICATION_INFO_HEADER *)pBuffer;
Trigger = NIHeader->pcent;
UserNotification = NIHeader->pceun;
RETAILMSG( 1, (TEXT("\tStatus %d\n"), NIHeader->dwStatus ));
RETAILMSG( 1, (TEXT("\tTrigger Type %d"), Trigger->dwType ));
switch( Trigger->dwType )
{
case CNT_EVENT:
RETAILMSG( 1, (TEXT(" Event\n")));
break;
case CNT_TIME:
RETAILMSG( 1, (TEXT(" Time\n")));
break;
case CNT_PERIOD:
RETAILMSG( 1, (TEXT(" Period\n")));
break;
case CNT_CLASSICTIME:
RETAILMSG( 1, (TEXT(" Classic Time\n")));
break;
}
RETAILMSG( 1, (TEXT("\tTrigger Event %d"), Trigger->dwEvent ));
switch( Trigger->dwEvent )
{
case NOTIFICATION_EVENT_NONE :
RETAILMSG( 1, (TEXT(" None\n")));
break;
case NOTIFICATION_EVENT_TIME_CHANGE :
RETAILMSG( 1, (TEXT(" Time Change\n")));
break;
case NOTIFICATION_EVENT_SYNC_END :
RETAILMSG( 1, (TEXT(" Sync End\n")));
break;
case NOTIFICATION_EVENT_ON_AC_POWER :
RETAILMSG( 1, (TEXT(" On AC Power\n")));
break;
case NOTIFICATION_EVENT_OFF_AC_POWER :
RETAILMSG( 1, (TEXT(" Off AC Power\n")));
break;
case NOTIFICATION_EVENT_NET_CONNECT :
RETAILMSG( 1, (TEXT(" Net Connect\n")));
break;
case NOTIFICATION_EVENT_NET_DISCONNECT :
RETAILMSG( 1, (TEXT(" Net Disconnect\n")));
break;
case NOTIFICATION_EVENT_DEVICE_CHANGE :
RETAILMSG( 1, (TEXT(" Device Change\n")));
break;
case NOTIFICATION_EVENT_IR_DISCOVERED :
RETAILMSG( 1, (TEXT(" IR Discovered\n")));
break;
case NOTIFICATION_EVENT_RS232_DETECTED :
RETAILMSG( 1, (TEXT(" RS232 Detected\n")));
break;
case NOTIFICATION_EVENT_RESTORE_END :
RETAILMSG( 1, (TEXT(" Restore End\n")));
break;
case NOTIFICATION_EVENT_WAKEUP :
RETAILMSG( 1, (TEXT(" Wakeup\n")));
break;
case NOTIFICATION_EVENT_TZ_CHANGE :
RETAILMSG( 1, (TEXT(" Timezone Change\n")));
break;
case NOTIFICATION_EVENT_MACHINE_NAME_CHANGE :
RETAILMSG( 1, (TEXT(" Machine Name Change\n")));
break;
}
RETAILMSG( 1, (TEXT("\tTrigger Application %s\n"),
Trigger->lpszApplication ));
RETAILMSG( 1, (TEXT("\tTrigger Arguments %s\n"),
Trigger->lpszArguments ));
RETAILMSG( 1, (TEXT("\tTrigger EndTime %d/%d/%d %d:%02d\n"),
Trigger->stEndTime.wMonth,
Trigger->stEndTime.wDay,
Trigger->stEndTime.wYear,
Trigger->stEndTime.wHour,
Trigger->stEndTime.wMinute ));
RETAILMSG( 1, (TEXT("\tTrigger StartTime %d/%d/%d %d:%02d\n"),
Trigger->stStartTime.wMonth,
Trigger->stStartTime.wDay,
Trigger->stStartTime.wYear,
Trigger->stStartTime.wHour,
Trigger->stStartTime.wMinute ));
if( UserNotification != NULL )
{
RETAILMSG( 1, (TEXT("\tUser Action %d "), UserNotification->ActionFlags));
if( UserNotification->ActionFlags & PUN_LED)
RETAILMSG( 1, (TEXT("LED ")));
if( UserNotification->ActionFlags & PUN_VIBRATE)
RETAILMSG( 1, (TEXT("Vibrate ")));
if( UserNotification->ActionFlags & PUN_DIALOG)
RETAILMSG( 1, (TEXT("Dialog ")));
if( UserNotification->ActionFlags & PUN_SOUND)
RETAILMSG( 1, (TEXT("Sound ")));
if( UserNotification->ActionFlags & PUN_REPEAT)
RETAILMSG( 1, (TEXT("Repeat ")));
RETAILMSG(1, (TEXT("\n")));
if( UserNotification->pwszDialogText != NULL )
{
RETAILMSG( 1, (TEXT("\tUser Dialog Title %s\n"),
UserNotification->pwszDialogTitle));
RETAILMSG( 1, (TEXT("\tUser Dialog Text %s\n"),
UserNotification->pwszDialogText));
}
if( UserNotification->ActionFlags & PUN_SOUND)
RETAILMSG( 1, (TEXT("\tUser Sound %s\n"),
UserNotification->pwszSound));
}
free( pBuffer );
}
free( hNotifications );
}
Num Notifications available 11
0 Bytes needed 232
Status 0
Trigger Type 4 Classic Time
Trigger Event 0 None
Trigger Application Windows\clock.exe
Trigger Arguments (NULL)
Trigger EndTime 0/0/0 0:00
Trigger StartTime 12/1/2008 5:00
User Action 31 LED Vibrate Dialog Sound Repeat
User Dialog Title Daily Alarm
User Dialog Text 6:00 AM 12/1/08
No description
User Sound Alarm1
1 Bytes needed 232
Status 0
Trigger Type 4 Classic Time
Trigger Event 0 None
Trigger Application Windows\clock.exe
Trigger Arguments (NULL)
Trigger EndTime 0/0/0 0:00
Trigger StartTime 12/2/2008 8:00
User Action 31 LED Vibrate Dialog Sound Repeat
User Dialog Title Daily Alarm
User Dialog Text 9:00 AM 12/2/08
No description
User Sound Alarm1
2 Bytes needed 120
Status 0
Trigger Type 2 Time
Trigger Event 0 None
Trigger Application clocknot.exe
Trigger Arguments AppRunAtTime
Trigger EndTime 0/0/0 0:00
Trigger StartTime 12/4/2008 23:00
3 Bytes needed 198
Status 0
Trigger Type 1 Event
Trigger Event 1 Time Change
Trigger Application \\.\Notifications\NamedEvents\SSTimeChange
Trigger Arguments AppRunAfterTimeChange
Trigger EndTime 0/0/0 0:00
Trigger StartTime 0/0/0 0:00
4 Bytes needed 134
Status 0
Trigger Type 1 Event
Trigger Event 1 Time Change
Trigger Application calnot.exe
Trigger Arguments AppRunAfterTimeChange
Trigger EndTime 0/0/0 0:00
Trigger StartTime 0/0/0 0:00
5 Bytes needed 128
Status 0
Trigger Type 1 Event
Trigger Event 10 Restore End
Trigger Application calnot.exe
Trigger Arguments AppRunAfterRestore
Trigger EndTime 0/0/0 0:00
Trigger StartTime 0/0/0 0:00
6 Bytes needed 132
Status 0
Trigger Type 1 Event
Trigger Event 10 Restore End
Trigger Application clocknot.exe
Trigger Arguments AppRunAfterRestore
Trigger EndTime 0/0/0 0:00
Trigger StartTime 0/0/0 0:00
7 Bytes needed 138
Status 0
Trigger Type 1 Event
Trigger Event 1 Time Change
Trigger Application clocknot.exe
Trigger Arguments AppRunAfterTimeChange
Trigger EndTime 0/0/0 0:00
Trigger StartTime 0/0/0 0:00
8 Bytes needed 136
Status 0
Trigger Type 1 Event
Trigger Event 1 Time Change
Trigger Application connmgr.exe
Trigger Arguments AppRunAfterTimeChange
Trigger EndTime 0/0/0 0:00
Trigger StartTime 0/0/0 0:00
9 Bytes needed 132
Status 0
Trigger Type 1 Event
Trigger Event 9 RS232 Detected
Trigger Application connmgr.exe
Trigger Arguments AppRunAtRs232Detect
Trigger EndTime 0/0/0 0:00
Trigger StartTime 0/0/0 0:00
10 Bytes needed 132
Status 0
Trigger Type 1 Event
Trigger Event 9 RS232 Detected
Trigger Application repllog.exe
Trigger Arguments AppRunAtRs232Detect
Trigger EndTime 0/0/0 0:00
Trigger StartTime 0/0/0 0:00