How to write an alarm program windows mobile app where the time is set by user,,,,,,
i'm trying to write an alarm program for PocketPc 6 emulator and for wince 6.0 ,,,,where the alarm time is set by user and at that pirticular time the win mobile has to give some alert message,,,,,
i tried using CeRunAppAtTime and CeSetUserNotification like
HANDLE hNotify;
SYSTEMTIME sysTime,sys;
CE_USER_NOTIFICATION ceNot;
GetSystemTime(&sysTime);//tryed GetLocalTime(&sys); also
sysTime.wHour = 14;
sysTime.wMinute= 20;
sysTime.wSecond= 00;
ceNot.ActionFlags = PUN_SOUND | PUN_VIBRATE | PUN_LED;
ceNot.pwszSound = L"\\Windows\\beep.wav";
hNotify = CeSetUserNotification(NULL,L"\\ResidentFlash\\my.exe",&sysTime,&ceNot);
but here as and when the control comes to this line itself it s performing all actions,,,,,,,,i dont want this kind of functionalities it has to perform action at the specified time,,,,,,,
Plz guide me the correct way to achieve this task,,,,,,,,,any reply s appreciated in advanc开发者_运维百科e,,,,,,thanks,,,,,,,,,
Your notification code is telling the OS to run your application at 14:20:00, so that's what will happen (I assume this is what you mean by "its performing all actions"). If you want it to do only a specific task inside your application, the easiest thing to do is to have it set a named system event like this:
CeSetUserNotification(NULL,
_T("\\\\.\\Notifications\\NamedEvents\\MyAppEvent"),
&time,
¬ification);
The same name will work for CeRunAppAtTime. Once you have set up the notification, waiot for the event in your app in a background thread:
hEvent CreateEvent(NULL, FALSE, FALSE, _T("MyAppEvent"));
while(TRUE)
{
if(WaitForSingleObject(hEvent, 5000) == WAIT_OBJECT_0)
{
// the notification has fired. Do something.
}
}
精彩评论