Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Tue, 18 Sep 2007 02:12:02 -0700,    group: microsoft.public.win32.programmer.tools        back       


System time change notification   
Hopefully, I am posting this question in the appropriate newsgroup.
I have a question regarding detecting system time change in a server 
application.
In a client/GUI application (i.e. application that has a WndProc) I can 
handle the WM_TIMECHANGE message.
However, I have a server application (a Web application, Win32 Service 
without a UI, etc…) where I need to detect the system time on such 
application. 
Is there something I am missing?  What API should I use?



-- 
Asher.
date: Tue, 18 Sep 2007 02:12:02 -0700   author:   Asher F. am

RE: System time change notification   
Hi Asher,

To ensure my reply is a best practice recommendation, I have discussed with 
some kernel expert internally. 

They confirmed that we must create a window to get notification from 
system. But since server application will run in Session 0 in Vista, I 
suspect if Session 0 isolation feature in Vista will affect this solution. 
Their comments below resolves my suspicion:

1. System broadcast messages like this will go to all topmost windows in 
all terminal sessions, so Session 0 isolation feature in Vista will not 
affect this solution. 
2. You need to create a separate thread to pump messages for this window. 
You can not rely on the service thread.
3. If you are using .Net in server application, you should PInvoke to the 
Win32 APIs (RegisterClass, CreateWindow, Get/DispatchMessage) to create the 
message loop and window instead of using .Net Winform message loops(this 
may cause some problem). 
4. Web applications are harder because they shouldn¡¯t maintain state.  
Like background threads and windows.  On the other hand, they shouldn¡¯t 
maintain state, like knowledge about the previous system time.

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to 
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues 
where an initial response from the community or a Microsoft Support 
Engineer within 1 business day is acceptable. Please note that each follow 
up response may take approximately 2 business days as the support 
professional working with you may need further investigation to reach the 
most efficient resolution. The offering is not appropriate for situations 
that require urgent, real-time or phone-based interactions or complex 
project analysis and dump analysis issues. Issues of this nature are best 
handled working with a dedicated Microsoft Support Engineer by contacting 
Microsoft Customer Support Services (CSS) at 
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
date: Wed, 19 Sep 2007 04:37:07 GMT   author:   (Jeffrey Tan[MSFT])

RE: System time change notification   
Hello Jefry,
 Thank you very much for your response.
 I will implement it.
 On the Web Application issue,you are correct that it shouldn't keep state.
 I mention web application as an example for an application that doesn't 
have a windows UI, it is not an actual issue for me.
Once again, thank you for your help.

-- 
Asher.


""Jeffrey Tan[MSFT]"" wrote:

> Hi Asher,
> 
> To ensure my reply is a best practice recommendation, I have discussed with 
> some kernel expert internally. 
> 
> They confirmed that we must create a window to get notification from 
> system. But since server application will run in Session 0 in Vista, I 
> suspect if Session 0 isolation feature in Vista will affect this solution. 
> Their comments below resolves my suspicion:
> 
> 1. System broadcast messages like this will go to all topmost windows in 
> all terminal sessions, so Session 0 isolation feature in Vista will not 
> affect this solution. 
> 2. You need to create a separate thread to pump messages for this window. 
> You can not rely on the service thread.
> 3. If you are using .Net in server application, you should PInvoke to the 
> Win32 APIs (RegisterClass, CreateWindow, Get/DispatchMessage) to create the 
> message loop and window instead of using .Net Winform message loops(this 
> may cause some problem). 
> 4. Web applications are harder because they shouldn¡¯t maintain state.  
> Like background threads and windows.  On the other hand, they shouldn¡¯t 
> maintain state, like knowledge about the previous system time.
> 
> Hope this helps.
> 
> Best regards,
> Jeffrey Tan
> Microsoft Online Community Support
> ==================================================
> Get notification to my posts through email? Please refer to 
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
> ications.
> 
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues 
> where an initial response from the community or a Microsoft Support 
> Engineer within 1 business day is acceptable. Please note that each follow 
> up response may take approximately 2 business days as the support 
> professional working with you may need further investigation to reach the 
> most efficient resolution. The offering is not appropriate for situations 
> that require urgent, real-time or phone-based interactions or complex 
> project analysis and dump analysis issues. Issues of this nature are best 
> handled working with a dedicated Microsoft Support Engineer by contacting 
> Microsoft Customer Support Services (CSS) at 
> http://msdn.microsoft.com/subscriptions/support/default.aspx.
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
> 
>
date: Thu, 20 Sep 2007 11:36:05 -0700   author:   Asher F. am

RE: System time change notification   
Hi Asher,

Glad to see my reply can help you. 

Regarding Windows Forms is not designed for use in a non-interactive 
context, this is documented in the MSDN link below:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.aspx
"Classes within the Windows Forms namespace are not supported for use 
within a Windows service. Trying to use these classes from within a service 
may produce unexpected problems, such as diminished service performance and 
run-time exceptions."

So, p/invoke the Win32 GUI APIs is the correct solution. Attached is a 
sample that captures WM_DEVICENOTIFICATION messages, which behave very much 
the same as time change notifications. You can download the sample project 
using Outlook Express not IE. If you fail to get it, please send an email 
to: jetan@online.microsoft.com(remove "online."), I will reply you with the 
sample project. 

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to 
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues 
where an initial response from the community or a Microsoft Support 
Engineer within 1 business day is acceptable. Please note that each follow 
up response may take approximately 2 business days as the support 
professional working with you may need further investigation to reach the 
most efficient resolution. The offering is not appropriate for situations 
that require urgent, real-time or phone-based interactions or complex 
project analysis and dump analysis issues. Issues of this nature are best 
handled working with a dedicated Microsoft Support Engineer by contacting 
Microsoft Customer Support Services (CSS) at 
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
date: Fri, 21 Sep 2007 01:59:47 GMT   author:   (Jeffrey Tan[MSFT])

RE: System time change notification   
Oh, sorry, I find that I forgot to attach the sample project. Here it is. 

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to 
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues 
where an initial response from the community or a Microsoft Support 
Engineer within 1 business day is acceptable. Please note that each follow 
up response may take approximately 2 business days as the support 
professional working with you may need further investigation to reach the 
most efficient resolution. The offering is not appropriate for situations 
that require urgent, real-time or phone-based interactions or complex 
project analysis and dump analysis issues. Issues of this nature are best 
handled working with a dedicated Microsoft Support Engineer by contacting 
Microsoft Customer Support Services (CSS) at 
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
date: Tue, 25 Sep 2007 03:24:57 GMT   author:   (Jeffrey Tan[MSFT])

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us