473,883 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to detect System Time Change in CompactFramewor k?

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.Win3 2.SystemEvents. TimeChanged" event. However, this is not
available under CF.

Any help welcome!

- José
May 24 '07 #1
3 6944
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/Per...e3e7a9c3c.aspx

"José Joye" <Me@me.comwro te in message
news:46******** **************@ news.sunrise.ch ...
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.Win3 2.SystemEvents. TimeChanged" event. However, this is not
available under CF.

Any help welcome!

- José

May 24 '07 #2
Jose,
Here is some C# example code, I hope it helps:

[DllImport("core dll.dll", EntryPoint = "CreateEven t", SetLastError = true)]
private static extern IntPtr CreateEvent(Int Ptr lpEventAttribut es,
bool bManualReset,
bool bInitialState, string spName);

[DllImport("core dll.dll", EntryPoint = "WaitForSingleO bject",
SetLastError = true)]
private static extern int WaitForSingleOb ject(IntPtr hHandle, UInt32
dwMilliseconds) ;

[DllImport("core dll.dll", EntryPoint = "CloseHandl e", SetLastError =
true)]
private static extern bool CloseHandle(Int Ptr hHandle);

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

private const int NOTIFICATION_EV ENT_TIME_CHANGE = 1;
private const UInt32 INFINITE = 0xFFFFFFFF;

public Form1()
{
InitializeCompo nent();
CeRunAppAtEvent ("\\\\.\\Notifi cations\\NamedE vents\\MyTimeNa medEvent",
NOTIFICATION_EV ENT_TIME_CHANGE );

Thread thread = new Thread(new ThreadStart(Thr eadProc));
thread.Start();
}

private void ThreadProc()
{
IntPtr hEvent = CreateEvent(Int Ptr.Zero, false, false,
"MyTimeNamedEve nt");

WaitForSingleOb ject(hEvent, INFINITE);

MessageBox.Show ("Time Event Occured");

CloseHandle(hEv ent);
}

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.Win3 2.SystemEvents. TimeChanged" event. However, this is not
available under CF.

Any help welcome!

- José
May 24 '07 #3
Thanks to both of you!

This is really usefull

- José
"dbgrick" <db*****@discus sions.microsoft .coma écrit dans le message de
news: 74************* *************** **...icrosof t.com...
Jose,
Here is some C# example code, I hope it helps:

[DllImport("core dll.dll", EntryPoint = "CreateEven t", SetLastError =
true)]
private static extern IntPtr CreateEvent(Int Ptr lpEventAttribut es,
bool bManualReset,
bool bInitialState, string spName);

[DllImport("core dll.dll", EntryPoint = "WaitForSingleO bject",
SetLastError = true)]
private static extern int WaitForSingleOb ject(IntPtr hHandle,
UInt32
dwMilliseconds) ;

[DllImport("core dll.dll", EntryPoint = "CloseHandl e", SetLastError
=
true)]
private static extern bool CloseHandle(Int Ptr hHandle);

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

private const int NOTIFICATION_EV ENT_TIME_CHANGE = 1;
private const UInt32 INFINITE = 0xFFFFFFFF;

public Form1()
{
InitializeCompo nent();
CeRunAppAtEvent ("\\\\.\\Notifi cations\\NamedE vents\\MyTimeNa medEvent",
NOTIFICATION_EV ENT_TIME_CHANGE );

Thread thread = new Thread(new ThreadStart(Thr eadProc));
thread.Start();
}

private void ThreadProc()
{
IntPtr hEvent = CreateEvent(Int Ptr.Zero, false, false,
"MyTimeNamedEve nt");

WaitForSingleOb ject(hEvent, INFINITE);

MessageBox.Show ("Time Event Occured");

CloseHandle(hEv ent);
}

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.Win 32.SystemEvents .TimeChanged" event. However, this is not
available under CF.

Any help welcome!

- José

May 24 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
4028
by: Stephane Belzile | last post by:
Is there a way I can detect in vb.Net the power has switched to a UPS unit in case of power failure? Thanks
23
6537
by: David McCulloch | last post by:
QUESTION-1: How can I detect if Norton Internet Security is blocking pop-ups? QUESTION-2a: How could I know if a particular JavaScript function has been declared? QUESTION-2b: How could I know if Window.Open has been redefined? BACKGROUND:
1
1455
by: Patrick Dugan | last post by:
Are there any source code examples of how to place an icon in the system tray using vb.net and a smart device? I have found examples for vb.net but they do not work for smart device (PPC) Can anyone point me to a specific example of placing an icon in the system tray of a PPC suing VB.NET?
1
15684
by: charlies224 | last post by:
Hi, I am writting a software that requires me to make sure the Num Lock is always on and Caps Lock is always off. First, I know how to detect if Num Lock or Caps Lock is on or off (if someone is interested, let me know and I will send you the codes). Once we know if the stat of Num Lock/ Caps Lock is not what we desired, we just send the Num Lock / Caps Lock key to change the stat. From most of
2
1934
by: eBob.com | last post by:
I've got the basics of an XML ini file working. I.E. I can stash away and retrieve user preferences. (Code below.) But how do I handle a new preference? Say I have A and B. And then I invent C. The first time the new version with C is run the XML file will not have a value for C. How do I detect that case? Somewhere I got the impression that I could use IsNull, but I was unable to find an example which I could apply to my code. My...
1
7610
by: Steve.Goodman | last post by:
Appologies if this has already been asked, but after scanning the web and this news group I could find no decent solution. We have a windows App that calls a webservice, using this bit of basic code. Dim objPreReq As PDCPreReq.PreReqs Dim objProxy As System.Net.WebProxy = System.Net.WebProxy.GetDefaultProxy objProxy.Credentials = System.Net.CredentialCache.DefaultCredentials
3
2784
by: José Joye | last post by:
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é
24
3045
by: dE|_ | last post by:
I have started looking into scripts for screen size detect with the intention of using them to pick from a number of CSS style sheets tailored to the size. Is there a good reason why this is not so commonly done? IE am I wasting my time? ---dE|_---
1
6222
by: Jeff | last post by:
I have located the following code and trying to change this so I know if the USB device has been inserted or removed. The problem I have is I alwayd get the Console.WriteLine("Usb removed") so I hope someone can point me to where I made my mistake . public void UsbEventArrived(object sender, EventArrivedEventArgs e) { //Get the Event object and display it foreach(PropertyData pd in e.NewEvent.Properties) {
0
9791
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10414
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9572
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7971
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7125
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5991
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4218
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3232
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.