views:

63

answers:

2

I have a time in the future when I want a notification to occur and need to know if ::CeSetUserNotificationEx expects UTC or local time in the stStartTime field of the CE_NOTIFICATION_TRIGGER structure if the dwType field is set to CNT_TIME?

+1  A: 

Use ::GetSystemTime() to fill up your stStartTime param, convert it to FILETIME through ::SystemTimeToFileTime(), cast the resulting FILETIME structure to a ULARGE_INTEGER structure, add the relevant milliseconds interval, cast back to FILETIME, convert to your stEndTime param with ::FileTimeToSystemTime().

See http://msdn.microsoft.com/en-us/library/aa908737.aspx for FILETIME arithmetics cheers, AR

Alain Rist
Thanks, but that doesn't help. I have a time in the future when I want the notification to occur and need to know if ::CeSetUserNotificationEx expects UTC or local time. I've edited the question to (hopefully) make that clearer.
Johann Gerell
Edited the answer as well: hope it is clearer :)
Alain Rist
@Alain: Thanks again, Alain, but you shoot beside the target... :-) That still doesn't tell me if ::CeSetUserNotificationEx expects UTC or local time. I have a time in the future, and *I* know if that time is UTC or local time, but if I don't know what the function wants, then I cannot just do your time arithemtic, which is what I already did anyway. I've now tested the stuff and written a separate answer.
Johann Gerell
A: 

After actually testing ::CeSetUserNotificationEx with both UTC and local time input, I'm in the position of answering my own question:

::CeSetUserNotificationEx wants local time.

Johann Gerell
This is OK as long as the user does not change the time settings. You should use an interval (compute it in UTC or local time as you want) with the current System time as I tried to explain in my answer.
Alain Rist
Hmmm... I'm not sure about that initial remark. In my tests I got the notification at the correct local time even if I made changes to the time settings between calling ::CeSetUserNotificationEx and the target time occuring. Maybe I misunderstood what you meant? (again... ;-)
Johann Gerell
@Alain: After some more weeks of testing things - when you said "change time settings", if by that you meant "change time zone", then you are correct. I'm monitoring appointments, and they will be pushed forward/backward automatically when the timezone changes. I get around that by also listening to timezone changes.
Johann Gerell