CeSetUserNotificationEx

< BACK  NEXT >
[oR]

So far, all the functions described in this chapter are available in the Windows CE operating system versions 2.0 and later. However, in Windows CE 2.12 and later, many of the notification functions (such as CeSetUserNotification, CeRunAppAtTime, and CeRunAppAtEvent) have been replaced with the single function CeSetUserNotificationEx. You should use this function if you do not require backwards compatibility with earlier Windows CE versions. CeSetUserNotificationEx provides additional capabilities not present in earlier operations systems, such as:

  • Specifying a time period (start time and end time) during which a notification is active. With CeSetUserNotification a notification is active from the start time until it is removed.

  • Specifying the command line arguments passed to an application launched by a notification rather than the standard arguments listed in Table 7.1.

Table 7.5 lists the CeSetUserNotificationEx arguments and return type. The function can be used to modify an existing notification by passing a valid notification handle as the first argument, or 0 to create a new notification.

Table 7.5. CeSetUserNotificationEx notification function
CeSetUserNotification
HANDLE hNotification, Handle of the notification to modify, or 0 for a new notification.
CE_NOTIFICATION_TRIGGER *pcnt Structure defining the type of notification.
CE_USER_NOTIFICATION *pceun Pointer to a user notification structure. This is the same structure used with CeSetUserNotification.
HANDLE Return Value Returns a HANDLE to the event.

The CE_NOTIFICATION_TRIGGER structure defines what type of notification is being created and what the notification will do. Table 7.6 lists the structure members.

Table 7.6. CE_NOTIFICATION_TRIGGER structure
Member Purpose
DWORD dwSize Size of the structure in bytes.
DWORD dwType

Type of notification:

CNT_EVENT System event notification.

CNT_TIME Time-based notification.

CNT_PERIOD Period-based notification using stStartTime and stEndTime.

CNT_CLASSICTIME Same behavior as calling the CeSetUser-Notification with standard command line values.

DWORD dwEvent If dwType == CNT_EVENT this member is initialized with a standard event constant, see Table 7.1.
WCHAR *lpszApplication Name of application to run.
WCHAR *lpszArguments Arguments to be passed to application. Must be NULL if dwType == CNT_CLASSICTIME.
SYSTEMTIME stStartTime Specifies the start time of the notification period.
SYSTEMTIME stEndTime Specifies the end time of the notification period.

The code in Listing 7.11 shows how CeSetUserNotification can be called to run Pocket Word at a specified time (10.15PM on the current day) with no command line argument being passed. No user notifications are required, so the CE_USER_NOTIFICATION structure pointer is passed as NULL.

Listing 7.11 Runs an application at a specified time using CeSetUserNotification
 void Listing7_11() {   CE_NOTIFICATION_TRIGGER unt;   CE_USER_NOTIFICATION cen;   SYSTEMTIME sysTime;   GetLocalTime(&sysTime);   sysTime.wHour = 22;   sysTime.wMinute = 15;   memset(&unt, 0, sizeof(unt));   unt.dwSize = sizeof(unt);   unt.dwType = CNT_TIME;   unt.lpszApplication = _T("\\windows\\pword.exe");   unt.lpszArguments = NULL; // no command line argument   unt.stStartTime = sysTime;   unt.stEndTime = sysTime;   HANDLE hNotify = CeSetUserNotificationEx(0,         &unt, NULL);   if(hNotify == NULL)     cout   _T("Could not set notification")   endl;   else     cout   _T("Notification set")   endl; } 

< BACK  NEXT >


Windows CE 3. 0 Application Programming
Windows CE 3.0: Application Programming (Prentice Hall Series on Microsoft Technologies)
ISBN: 0130255920
EAN: 2147483647
Year: 2002
Pages: 181

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net