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] "José Joye" wrote:
> 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é
>
>
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] > 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
> "José Joye" wrote:
>
>> 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é
>>
>>
>>