The function CeRunAppAtTime sets an application to be run at a time specified in a SYSTEMTIME structure. Listing 7.1 shows how this function can be called to run Pocket Word at 7.20AM on the current day. Note that the file notify.h must be included when using notification functions. The code gets the current local time through calling GetLocalTime, and sets the hour to 7 and minute to 20. The call to CeRunAppAtTime is passed the name of the application to run and the time to run it. Listing 7.1 Runs an application at a specified time#include <notify.h> void Listing7_1() { SYSTEMTIME sysTime; GetLocalTime(&sysTime); sysTime.wHour = 7; sysTime.wMinute = 20; if(!CeRunAppAtTime( _T("\\Windows\\Pword.exe"), &sysTime)) cout _T("Cannot set application to run") endl; else cout _T("App set to run at specified time") endl; } Windows CE will run the application at the specified time and pass the command line parameter "AppRunAtTime". For this reason, Pocket Word will prompt you to create a new file called "AppRunAtTime.Pwd" when it runs. If the time specified in the SYSTEMTIME structure is in the past the application will run immediately. An application can only have a single CeRunAppAtTime request associated with it. If another call is made to CeRunAppAtTime for the same application, the previous request is overwritten with the new time. A CeRunAppAtTime request for an application can be removed by passing NULL pointer for the SYSTEMTIME pointer.
|