Groups | Blog | Home
all groups > dotnet compact framework > may 2007 >

dotnet compact framework : How to detect System Time Change in CompactFramework?



dbgrick
5/24/2007 7:35:00 AM
Jose,
Here is some C# example code, I hope it helps:

[DllImport("coredll.dll", EntryPoint = "CreateEvent", SetLastError = true)]
private static extern IntPtr CreateEvent(IntPtr lpEventAttributes,
bool bManualReset,
bool bInitialState, string spName);

[DllImport("coredll.dll", EntryPoint = "WaitForSingleObject",
SetLastError = true)]
private static extern int WaitForSingleObject(IntPtr hHandle, UInt32
dwMilliseconds);

[DllImport("coredll.dll", EntryPoint = "CloseHandle", SetLastError =
true)]
private static extern bool CloseHandle(IntPtr hHandle);

[DllImport("coredll.dll", EntryPoint = "CeRunAppAtEvent",
SetLastError = true)]
private static extern bool CeRunAppAtEvent(string pszAppName, long
lwichEvent);

private const int NOTIFICATION_EVENT_TIME_CHANGE = 1;
private const UInt32 INFINITE = 0xFFFFFFFF;

public Form1()
{
InitializeComponent();


CeRunAppAtEvent("\\\\.\\Notifications\\NamedEvents\\MyTimeNamedEvent",
NOTIFICATION_EVENT_TIME_CHANGE);

Thread thread = new Thread(new ThreadStart(ThreadProc));
thread.Start();
}

private void ThreadProc()
{
IntPtr hEvent = CreateEvent(IntPtr.Zero, false, false,
"MyTimeNamedEvent");

WaitForSingleObject(hEvent, INFINITE);

MessageBox.Show("Time Event Occured");

CloseHandle(hEvent);
}

Rick D.
Contractor
[quoted text, click to view]
ctacke/
5/24/2007 9:59:08 AM
There is a system event that fires (actually a pair, one for time, another
for time zone). You can P/Invokce CeRunAppAtEvent[1] and get them. They
are also wrapped in the OpenNETCF Smart Device Framework[2].


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com

[1] http://msdn2.microsoft.com/en-us/library/ms913956.aspx
[2]
http://blog.opennetcf.org/ctacke/PermaLink,guid,1e5cdaf9-dc69-4d25-9656-6cfe3e7a9c3c.aspx



[quoted text, click to view]

José Joye
5/24/2007 3:41:32 PM
In my application (written for Compact Framework 2.0 ), I have to be
informed whenever a system Time change occurs (NTP, daylight saving, ...).
Under the normal framework, I'm able to use the
"Microsoft.Win32.SystemEvents.TimeChanged" event. However, this is not
available under CF.

Any help welcome!

- José

José Joye
5/24/2007 7:41:35 PM
Thanks to both of you!

This is really usefull

- José
"dbgrick" <dbgrick@discussions.microsoft.com> a écrit dans le message de
news: 742F44FF-0E9E-41FF-80A1-196396C77898@microsoft.com...
[quoted text, click to view]

AddThis Social Bookmark Button