Starting an Application on an Event

< BACK  NEXT >
[oR]

The function CeRunAppAtEvent allows a program to be run when one of the following events occur:

  • NOTIFICATION_EVENT_SYNC_END. When data synchronization finishes.

  • NOTIFICATION_EVENT_DEVICE_CHANGE. When a PC Card device is changed.

  • NOTIFICATION_EVENT_RS232_DETECTED. When an RS232 connection is made.

  • NOTIFICATION_EVENT_TIME_CHANGE. When the system time is changed.

  • NOTIFICATION_EVENT_RESTORE_END. When a full device restore completes.

Listing 7.4 shows a call to CeRunAppAtEvent that sets Notify.exe to run when ActiveSync synchronization completes.

Listing 7.4 Runs application on an event
 void Listing7_4() {   if(!CeRunAppAtEvent(_T("\\Notify.exe"),             NOTIFICATION_EVENT_SYNC_END))     cout    _T("Cannot set application to run")             endl;   else     cout         _T("Notify.exe will run when sync finishes")         endl; } 

The application will be run with a command line string whose value depends on the event being used, and these strings as shown in Table 7.1.

Table 7.1. Command line strings used with CeRunAppAtEvent
Constant Value
APP_RUN_AFTER_SYNC "AppRunAfterSync"
APP_RUN_AT_DEVICE_CHANGE "AppRunDeviceChange"
APP_RUN_AT_RS232_DETECT "AppRunAtRs232Detect"
APP_RUN_AFTER_RESTORE "AppRunAfterRestore"

The application specified in CeRunAppAtEvent will be run each time the specified event occurs. All events associated with an application can be removed by calling the function CeRunAppAtEvent with NOTIFICATION_EVENT_NONE as the last parameter (Listing 7.5).

Listing 7.5 Removes an application event
 void Listing7_5() {   if(!CeRunAppAtEvent(_T("\\Notify.exe"),           NOTIFICATION_EVENT_NONE))     cout   _T("Cannot stop application event.")            endl;   else     cout   _T("Application event removed.")            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