Hi Darren,

we use the code bellow. Just supply your definition for appFileCreator.

The function (proc) is supposed to be in the 1st segment.

Have a nice day.

With best regards,
    Jan Slodicka
    Resco, Palm Division



static int RegisterProcedureNotification( Boolean bRegister, UInt32 notifyType, 
           SysNotifyProcPtr proc, void *data, Int8 priority)
{
 LocalID dbID = FindDatabaseByTypeCreator('appl', appFileCreator) ;
 int err = dmErrCantFind ;

 if( dbID )
 {
  DmOpenRef dbRef = DmOpenDBNoOverlay(0, dbID, dmModeReadOnly) ;
  if( dbRef )
  {
   MemHandle h = DmGetResource('code',1) ;
   if( h )
   {
    if( bRegister )
    {
     MemHandleLock(h) ;
     
     err = DmDatabaseProtect(0, dbID, true) ;
     if( err == 0 )
     {
      err = SysNotifyRegister(0, dbID, notifyType, proc, priority, data) ;
      if( err )
       DmDatabaseProtect(0, dbID, false) ;
     }
     
     if( err )
      MemHandleUnlock(h) ;
    }
    else
    {
     // Unprotect & Unlock only if we *really* were registered...
     err = SysNotifyUnregister(0, dbID, notifyType, priority) ;
     if( err == 0 )
     {
      MemHandleUnlock(h) ;
      DmDatabaseProtect(0, dbID, false) ;
     }
    }
    
    DmReleaseResource(h) ;
   }
   DmCloseDatabase(dbRef) ;
  }
 }

 return err ;
}



  ----- Original Message ----- 
  From: Darren Barnes 
  To: Palm Developer Forum 
  Sent: Saturday, September 27, 2008 11:31 AM
  Subject: Notifications, help please


Helloam using notifications 
:sysNotifySleepNotifyEventsysNotifyEarlyWakeupEventsysNotifyGotUsersAttentionto 
try and detect when the device is woken up using a keypress(user) or an 
alarm(system), so that the auto-off timer can be automaticaly set totimes that 
will conserve battery power.The notifications for sleep & wake are registered 
or unregistered depending ona selection made from a desk accessory, (this means 
passing a pointer to
 a functionfor the notifs handlers as there is no PilotMain in a desk 
accessory).The sysNotifyGotUsersAttention notif is registered in the sleep 
notif handler, so that if the device wakes with an alarm sysAutoOff can be set 
to a few secs.Anyway, the functions work well for the first alarm but on 
following alarms (if repeat alarms are set)it resets.Reading the SDK 
documention, there is advice there about locking a function pointer,how is this 
done ? Is the pointer that is passed to the sysNotifyRegister a pointer to an 
abosulte address inthe storage heap, or is it a pointer that is an offset from 
the start of the database
 thatspassed?Any help please, many thanks and regardsDarren   


-- 
For information on using the ACCESS Developer Forums, or to unsubscribe, please 
see http://www.access-company.com/developers/forums/
-- 
For information on using the ACCESS Developer Forums, or to unsubscribe, please 
see http://www.access-company.com/developers/forums/

Reply via email to