CeSetUserNotificationEx (Windows CE 5.0)
This function creates a new user notification or modifies an existing one.
HANDLE CeSetUserNotificationEx(HANDLEhNotification,CE_NOTIFICATION_TRIGGER* pcnt,CE_USER_NOTIFICATION* pceun );
Parameters
- hNotification
[in] Handle to the notification to overwrite or 0 to add a new notification. - pcnt
[in] Pointer to a CE_NOTIFICATION_TRIGGER structure that defines what event activates a notification. - pceun
[in] Pointer to the CE_USER_NOTIFICATION structure that defines how the system should respond when a notification occurs. For example, the system could launch a dialog box or another application.
Return Values
Returns a handle to the notification event if successful. This handle can then be used with the other Notify functions. Returns NULL if unsuccessful.
Remarks
If the scheduled time lies within the platform-dependent period defined by the accuracy of the real-time clock (RTC), the notification may be scheduled immediately. The accuracy may be retrieved by IOCTL_KLIB_GETALARMRESOLUTION and may range from 1 to 60 seconds. If the platform does not implement IOCTL_KLIB_GETALARMRESOLUTION, the default RTC accuracy of 10 seconds is assumed.
To delete a notification and release the handle, use the handle returned by CeSetUserNotification in a call to CeClearUserNotification. To overwrite a notification, use the returned handle in another call to CeSetUserNotificationEx.
Code Example
The following code example demonstrates how to use CeSetUserNotificationEx.
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.
HANDLE hEvent;
HANDLE hNotify;
BOOL bTriggered;
SYSTEMTIME curSysTime;
SYSTEMTIME endSysTime;
CE_NOTIFICATION_TRIGGER trigger;
bTriggered = FALSE;
trigger.dwSize = sizeof(CE_NOTIFICATION_TRIGGER);
// System event notification
trigger.dwType = CNT_EVENT;
// The device disconnected from a network
trigger.dwEvent = NOTIFICATION_EVENT_NET_DISCONNECT;
// this will be a named event
trigger.lpszApplication = _T("\\\\.\\Notifications\\NamedEvents\\MyTestEvent\0");
trigger.lpszArguments = NULL;
// set start and end of notification period
GetSystemTime( &curSysTime );
endSysTime = curSysTime;
endSysTime.wYear = endSysTime.wYear + 20;
trigger.stStartTime = curSysTime;
trigger.stEndTime = endSysTime;
// create a named event
hEvent = CreateEvent( NULL, FALSE, FALSE, _T("MyTestEvent") );
// if named event was created
if( hEvent )
{
// create user notification
hNotify = CeSetUserNotificationEx( 0, &trigger, NULL );
// if user notification was created
if(hNotify )
{
// wait for event to be triggered
while(!bTriggered)
{
// wait for my event
if( WaitForSingleObject( hEvent, INFINITE ) != WAIT_OBJECT_0 )
{
RETAILMSG(1, (L"Unknown Event signaled") );
}
else
{
// my event was triggered
RETAILMSG(1, (L"My Event signaled") );
bTriggered = TRUE;
}
}
}
else
{
RETAILMSG(1, (L" CeSetUserNotificationEx failed") );
}
}
else
{
RETAILMSG(1, (L"CreateEvent failed") );
}
Requirements
OS Versions: Windows CE 2.12 and later.
Header: Notify.h.
Link Library: Coredll.lib.
See Also
CE_USER_NOTIFICATION | CE_NOTIFICATION_TRIGGER | IOCTL_KLIB_GETALARMRESOLUTION | Notify Functions
Send Feedback on this topic to the authors