There is an approach described here: http://www.c-sharpcorner.com/UploadFile/scottlysle/TimeSinceBootCS06052008055807AM/TimeSinceBootCS.aspx
However, it is not compatible with th开发者_StackOverflowe .NET Compact Framework.
Can anyone recommend a way to obtain the time (in seconds) since the system/device was booted up that's compatible with the compact framework?
Thanks in advance :)
Assuming that bug-ridden OS is okay with battery, time (as entire Windows family is skewing challenged), and assuming you will ensure to call it carefully enough to avoid wrapping (or use other mechanisms like persistance) on c20-30 days you get with GetTickCount/PInvoke or System.Environment.TickCount... just construct the DateTime from DateTime.Now (or utc variant, depending on what you're doing) and subtract the seconds/milliseconds.
精彩评论