You can't stop it, but you can record it using the notify Ben mentions.  Here 
is some code I use to record the time change.  I send it up to the server later.

-Dave


UInt32 PilotMain (UInt16 cmd, Ptr cmdPBP, UInt16 launchFlags)
{
    Err error;
    SysNotifyParamType *params = (SysNotifyParamType*) cmdPBP;
    Int32 *delta;
    LocalID dbIDP;
    UInt16 cardNoP;
    
    switch (cmd){
        case sysAppLaunchCmdNormalLaunch:
            error = RomVersionCompatible (MinVersion, launchFlags);
            if (error) 
                return error;
            error = AppStart();
            if (error) 
                return error;
            FrmGotoForm(LoginForm);
            AppEventLoop();
            AppStop();
            break;

        case sysAppLaunchCmdSystemReset:
            // Register this application to respond to TimeChangeEvent when the 
system resets.
            SysCurAppDatabase (&cardNoP, &dbIDP);
            SysNotifyRegister(cardNoP, dbIDP, sysNotifyTimeChangeEvent, NULL, 
sysNotifyNormalPriority, NULL);
            break;
        
        case sysAppLaunchCmdNotify:  
            // Respond to time change event and record in database.  No access 
to global vars
            
            if (params->notifyType == sysNotifyTimeChangeEvent) {
                delta = (Int32*)params->notifyDetailsP;  // notifyDetailsP 
contains a pointer to the num of seconds changed

                // Only record the time change in the database if it exceeds 
MAX_TIME_CHANGE 
                if (Abs(*delta) > MAX_TIME_CHANGE) {
                    DateTimeType ct;
                    char CurrentDateTime[12];
                    EmployeeInfoPtr emp;
                    TimeChangePtr tChange;
                    MemHandle structHandle;
                    DmOpenRef TimeChangeDB;
                    MemPtr structPtr;
                    UInt16 index = dmMaxRecordIndex;
                    UInt32 exit_time;
                 
                    tChange = (TimeChangePtr)MemPtrNew(sizeof(TimeChange));

                    TimSecondsToDateTime(TimGetSeconds() - *delta, &ct);
                    DateToAscii(ct.month, ct.day, ct.year, dfMDYWithSlashes, 
CurrentDateTime);
                    StrCopy((CharPtr)&tChange->change_date, CurrentDateTime);

                    TimeToAscii(ct.hour, ct.minute, tfColonAMPM, 
CurrentDateTime);
                    StrCopy((CharPtr)&tChange->change_time, CurrentDateTime);

                    // Record num of seconds the clock was changed by
                    tChange->delta = *delta;

                    // Write the record to the TimeChange database.
                    error = OpenOrCreateDB(&TimeChangeDB, TimeChangeDBType, 
appFileCreator, dmModeReadWrite, TimeChangeDBName);
                    if (!error) {
                        structHandle = DmNewRecord(TimeChangeDB, &index, 
sizeof(TimeChange));
                        structPtr = MemHandleLock(structHandle);
                        DmWrite(structPtr, 0, tChange, sizeof(TimeChange));
                        MemHandleUnlock(structHandle);
                        DmReleaseRecord(TimeChangeDB, index, true);
                        DmCloseDatabase(TimeChangeDB);
                    }
                    MemPtrFree(tChange);
                }
            }
            break; 
    }
    return 0;
}


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/

Reply via email to