CeSetUserNotificationEx

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 *pcntStructure defining the type of notification.
CE_USER_NOTIFICATION *pceunPointer to a user notification structure. This is the same structure used with CeSetUserNotification.
HANDLE Return ValueReturns 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
MemberPurpose
DWORD dwSizeSize 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 dwEventIf dwType == CNT_EVENT this member is initialized with a standard event constant, see Table 7.1.
WCHAR *lpszApplicationName of application to run.
WCHAR *lpszArgumentsArguments to be passed to application. Must be NULL if dwType == CNT_CLASSICTIME.
SYSTEMTIME stStartTimeSpecifies the start time of the notification period.
SYSTEMTIME stEndTimeSpecifies 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;
}

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.91.44