Running an Application at a Specified Time

< BACK  NEXT >
[oR]

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.


< 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