<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.1.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Get/Set Windows Mobile 5 date/time using C#.NET</title>
	<link>http://www.longshadow.com.au/getset-windows-mobile-5-datetime-using-cnet/</link>
	<description>Just another WordPress weblog</description>
	<pubDate>Thu, 29 Jul 2010 23:52:29 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.1.2</generator>

	<item>
		<title>By: Ellis</title>
		<link>http://www.longshadow.com.au/getset-windows-mobile-5-datetime-using-cnet/#comment-4</link>
		<author>Ellis</author>
		<pubDate>Tue, 10 Jul 2007 16:55:26 +0000</pubDate>
		<guid>http://www.longshadow.com.au/getset-windows-mobile-5-datetime-using-cnet/#comment-4</guid>
					<description>What is this "GetServerHeaders()" function?  It doesn't compile and there is no reference to it in MSDN.</description>
		<content:encoded><![CDATA[<p>What is this &#8220;GetServerHeaders()&#8221; function?  It doesn&#8217;t compile and there is no reference to it in MSDN.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Ellis</title>
		<link>http://www.longshadow.com.au/getset-windows-mobile-5-datetime-using-cnet/#comment-5</link>
		<author>Ellis</author>
		<pubDate>Tue, 10 Jul 2007 17:00:50 +0000</pubDate>
		<guid>http://www.longshadow.com.au/getset-windows-mobile-5-datetime-using-cnet/#comment-5</guid>
					<description>Never mind ... figured it out.  You didn't have a class declaration above.  I was thinking you were attempting to use a .NET class and didn't even look at the possibility that it was one of your own.  Sorry for entering the comment above.</description>
		<content:encoded><![CDATA[<p>Never mind &#8230; figured it out.  You didn&#8217;t have a class declaration above.  I was thinking you were attempting to use a .NET class and didn&#8217;t even look at the possibility that it was one of your own.  Sorry for entering the comment above.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: susmitha</title>
		<link>http://www.longshadow.com.au/getset-windows-mobile-5-datetime-using-cnet/#comment-8</link>
		<author>susmitha</author>
		<pubDate>Thu, 13 Dec 2007 18:32:20 +0000</pubDate>
		<guid>http://www.longshadow.com.au/getset-windows-mobile-5-datetime-using-cnet/#comment-8</guid>
					<description>Hi,
I have same exact problem, I am going find a fix for it, my users are not very tech savvy, so they encounter this problem quite often..
I am going to get the server time form my server and the server date doesn't match with device time, I will give a warning, the time from the Google server returns GMT time, that will not help me.. Is there a way to find it from SIM card?
Thanks for the posting!
Susmitha</description>
		<content:encoded><![CDATA[<p>Hi,<br />
I have same exact problem, I am going find a fix for it, my users are not very tech savvy, so they encounter this problem quite often..<br />
I am going to get the server time form my server and the server date doesn&#8217;t match with device time, I will give a warning, the time from the Google server returns GMT time, that will not help me.. Is there a way to find it from SIM card?<br />
Thanks for the posting!<br />
Susmitha</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Mark</title>
		<link>http://www.longshadow.com.au/getset-windows-mobile-5-datetime-using-cnet/#comment-9</link>
		<author>Mark</author>
		<pubDate>Fri, 14 Dec 2007 23:46:15 +0000</pubDate>
		<guid>http://www.longshadow.com.au/getset-windows-mobile-5-datetime-using-cnet/#comment-9</guid>
					<description>Hello Susmitha. You are correct that google will return a UTC/GMT time. This should be okay as long as the time zone is set correctly on the device. In fact UTC times are preferable for this reason.</description>
		<content:encoded><![CDATA[<p>Hello Susmitha. You are correct that google will return a UTC/GMT time. This should be okay as long as the time zone is set correctly on the device. In fact UTC times are preferable for this reason.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Ram</title>
		<link>http://www.longshadow.com.au/getset-windows-mobile-5-datetime-using-cnet/#comment-22</link>
		<author>Ram</author>
		<pubDate>Sat, 26 Apr 2008 06:39:20 +0000</pubDate>
		<guid>http://www.longshadow.com.au/getset-windows-mobile-5-datetime-using-cnet/#comment-22</guid>
					<description>Hey ,

 It is good piece of code works like champ !!! I did test this code on my Pocket PC 2003 and it works perfect.

I am wondering if there is any VC++ / MFC alternative code for the same. It seems that DateTime, HttpWebRequest, Response .. etc are not available for MFC or Win32. I would really appreciate if someone could point me equalent Win32 / MFC API to acheivi this functionality.</description>
		<content:encoded><![CDATA[<p>Hey ,</p>
<p> It is good piece of code works like champ !!! I did test this code on my Pocket PC 2003 and it works perfect.</p>
<p>I am wondering if there is any VC++ / MFC alternative code for the same. It seems that DateTime, HttpWebRequest, Response .. etc are not available for MFC or Win32. I would really appreciate if someone could point me equalent Win32 / MFC API to acheivi this functionality.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Ashish</title>
		<link>http://www.longshadow.com.au/getset-windows-mobile-5-datetime-using-cnet/#comment-24</link>
		<author>Ashish</author>
		<pubDate>Sat, 17 May 2008 07:02:35 +0000</pubDate>
		<guid>http://www.longshadow.com.au/getset-windows-mobile-5-datetime-using-cnet/#comment-24</guid>
					<description>HI,

I am facing the same problem in Intermec CN3 (Windows Mobile 5.0). When battery down, time settings revert to default value.

I tried the code you provide, but it is not working. Sometimes errors are coming...
1. PI invoke failed 
2. Specified method not found.

Could you please help me to solve this issue. asap

Thanks and Regards

Ashish</description>
		<content:encoded><![CDATA[<p>HI,</p>
<p>I am facing the same problem in Intermec CN3 (Windows Mobile 5.0). When battery down, time settings revert to default value.</p>
<p>I tried the code you provide, but it is not working. Sometimes errors are coming&#8230;<br />
1. PI invoke failed<br />
2. Specified method not found.</p>
<p>Could you please help me to solve this issue. asap</p>
<p>Thanks and Regards</p>
<p>Ashish</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Nitin Singh</title>
		<link>http://www.longshadow.com.au/getset-windows-mobile-5-datetime-using-cnet/#comment-25</link>
		<author>Nitin Singh</author>
		<pubDate>Fri, 13 Jun 2008 16:31:51 +0000</pubDate>
		<guid>http://www.longshadow.com.au/getset-windows-mobile-5-datetime-using-cnet/#comment-25</guid>
					<description>Hi,
     I used the same code to change time of my PDA having Windows Moblie 5.0 O/S according to my server but i am only getting time from my  server,time is not being set as the method "UpdateSystemTime()" and "SetSystemTime()" are not working.I am giving the code which i have used to to update Date/Time of PDA with our server.


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
//using System.Timers;
using System.Runtime.InteropServices;
using System.Threading;
using System.Net;

namespace DeviceApplication1
{
    public partial class Form1 : Form { 
       public Form1() {
            InitializeComponent();

       }
       struct SYSTEMTIME {
            public void LoadDateTime(DateTime dateTime) {
                this.Year = (UInt16)dateTime.Year;
                this.Month = (UInt16)dateTime.Month;
                this.Day = (UInt16)dateTime.Day;
                this.Hour = (UInt16)dateTime.Hour;
                this.Minute = (UInt16)dateTime.Minute;
                this.Second = (UInt16)dateTime.Second;
                this.MilliSecond = (UInt16)dateTime.Millisecond;
            }
            public UInt16 Year;
            public UInt16 Month;
            public UInt16 Day;
            public UInt16 Hour;
            public UInt16 Minute;
            public UInt16 Second;
            public UInt16 MilliSecond;
           
        }

        [DllImport("Coredll.dll", EntryPoint = "SetSystemTime")]

        private static extern bool SetSystemTime(ref SYSTEMTIME st);

        public void  UpdateSystemTime() {
            textBox1.Text = GetServerTime("http://www.google.com").ToString();
            DateTime serverTime = GetServerTime("http://www.google.com");
            serverTime = serverTime.ToUniversalTime();
            SYSTEMTIME sysTime = new SYSTEMTIME();
            sysTime.LoadDateTime(serverTime);
            bool yesno = SetSystemTime(ref sysTime);
            if (yesno.Equals(true))
                MessageBox.Show("Success in setting time");
            else
                MessageBox.Show("Failure in setting time");
        }
        //#endregion CorrectTime

        public static string GetHeader(string url, string header)
        {
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
            req.Method = "HEAD";
           
            HttpWebResponse resp = (HttpWebResponse)req.GetResponse();

           
            return resp.Headers.Get(header);

        }

       public static DateTime GetServerTime(string url)
        {
            string dateHeader = GetHeader(url, "Date");
            return DateTime.Parse(dateHeader);
        }



        private void button1_Click_1(object sender, EventArgs e)
        {
            string str;
            str = "http://www.google.com";
            button1.Text = "DisplayTime1";
            textBox1.Text = GetServerTime(str).ToString();
       

        }

        private void BtnOK_Click_1(object sender, EventArgs e)
        {
            BtnOK.Text = "Clicked1";
             UpdateSystemTime();
           
        }

     }
}


Note:I want to use my home server in place of "www.google.com".

Now kindly guide me why the method "SetSystemTime()" is not working to set the PDA time?? I have used this code in "DeviceApplication" in VC#.NET environment.

Regards:
Nitin Singh</description>
		<content:encoded><![CDATA[<p>Hi,<br />
     I used the same code to change time of my PDA having Windows Moblie 5.0 O/S according to my server but i am only getting time from my  server,time is not being set as the method &#8220;UpdateSystemTime()&#8221; and &#8220;SetSystemTime()&#8221; are not working.I am giving the code which i have used to to update Date/Time of PDA with our server.</p>
<p>using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
//using System.Timers;<br />
using System.Runtime.InteropServices;<br />
using System.Threading;<br />
using System.Net;</p>
<p>namespace DeviceApplication1<br />
{<br />
    public partial class Form1 : Form {<br />
       public Form1() {<br />
            InitializeComponent();</p>
<p>       }<br />
       struct SYSTEMTIME {<br />
            public void LoadDateTime(DateTime dateTime) {<br />
                this.Year = (UInt16)dateTime.Year;<br />
                this.Month = (UInt16)dateTime.Month;<br />
                this.Day = (UInt16)dateTime.Day;<br />
                this.Hour = (UInt16)dateTime.Hour;<br />
                this.Minute = (UInt16)dateTime.Minute;<br />
                this.Second = (UInt16)dateTime.Second;<br />
                this.MilliSecond = (UInt16)dateTime.Millisecond;<br />
            }<br />
            public UInt16 Year;<br />
            public UInt16 Month;<br />
            public UInt16 Day;<br />
            public UInt16 Hour;<br />
            public UInt16 Minute;<br />
            public UInt16 Second;<br />
            public UInt16 MilliSecond;</p>
<p>        }</p>
<p>        [DllImport(&#8221;Coredll.dll&#8221;, EntryPoint = &#8220;SetSystemTime&#8221;)]</p>
<p>        private static extern bool SetSystemTime(ref SYSTEMTIME st);</p>
<p>        public void  UpdateSystemTime() {<br />
            textBox1.Text = GetServerTime(&#8221;http://www.google.com&#8221;).ToString();<br />
            DateTime serverTime = GetServerTime(&#8221;http://www.google.com&#8221;);<br />
            serverTime = serverTime.ToUniversalTime();<br />
            SYSTEMTIME sysTime = new SYSTEMTIME();<br />
            sysTime.LoadDateTime(serverTime);<br />
            bool yesno = SetSystemTime(ref sysTime);<br />
            if (yesno.Equals(true))<br />
                MessageBox.Show(&#8221;Success in setting time&#8221;);<br />
            else<br />
                MessageBox.Show(&#8221;Failure in setting time&#8221;);<br />
        }<br />
        //#endregion CorrectTime</p>
<p>        public static string GetHeader(string url, string header)<br />
        {<br />
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);<br />
            req.Method = &#8220;HEAD&#8221;;</p>
<p>            HttpWebResponse resp = (HttpWebResponse)req.GetResponse();</p>
<p>            return resp.Headers.Get(header);</p>
<p>        }</p>
<p>       public static DateTime GetServerTime(string url)<br />
        {<br />
            string dateHeader = GetHeader(url, &#8220;Date&#8221;);<br />
            return DateTime.Parse(dateHeader);<br />
        }</p>
<p>        private void button1_Click_1(object sender, EventArgs e)<br />
        {<br />
            string str;<br />
            str = &#8220;http://www.google.com&#8221;;<br />
            button1.Text = &#8220;DisplayTime1&#8243;;<br />
            textBox1.Text = GetServerTime(str).ToString();</p>
<p>        }</p>
<p>        private void BtnOK_Click_1(object sender, EventArgs e)<br />
        {<br />
            BtnOK.Text = &#8220;Clicked1&#8243;;<br />
             UpdateSystemTime();</p>
<p>        }</p>
<p>     }<br />
}</p>
<p>Note:I want to use my home server in place of &#8220;www.google.com&#8221;.</p>
<p>Now kindly guide me why the method &#8220;SetSystemTime()&#8221; is not working to set the PDA time?? I have used this code in &#8220;DeviceApplication&#8221; in VC#.NET environment.</p>
<p>Regards:<br />
Nitin Singh</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Alexander Marin</title>
		<link>http://www.longshadow.com.au/getset-windows-mobile-5-datetime-using-cnet/#comment-26</link>
		<author>Alexander Marin</author>
		<pubDate>Thu, 03 Jul 2008 11:05:24 +0000</pubDate>
		<guid>http://www.longshadow.com.au/getset-windows-mobile-5-datetime-using-cnet/#comment-26</guid>
					<description>Hi all,
in GetHeader you need close HttpWebResponse
resp.Close();

public static string GetHeader(string url, string header)
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "HEAD";
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
string response_str = resp.Headers.Get(header);
resp.Close();
return response_str;
}

from MSDN:

The Close method closes the response stream and releases the connection to the resource for reuse by other requests.

You must call either the Stream..::.Close or the HttpWebResponse..::.Close method to close the stream and release the connection for reuse. It is not necessary to call both Stream..::.Close and HttpWebResponse..::.Close, but doing so does not cause an error. Failure to close the stream can cause your application to run out of connections.</description>
		<content:encoded><![CDATA[<p>Hi all,<br />
in GetHeader you need close HttpWebResponse<br />
resp.Close();</p>
<p>public static string GetHeader(string url, string header)<br />
{<br />
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);<br />
req.Method = &#8220;HEAD&#8221;;<br />
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();<br />
string response_str = resp.Headers.Get(header);<br />
resp.Close();<br />
return response_str;<br />
}</p>
<p>from MSDN:</p>
<p>The Close method closes the response stream and releases the connection to the resource for reuse by other requests.</p>
<p>You must call either the Stream..::.Close or the HttpWebResponse..::.Close method to close the stream and release the connection for reuse. It is not necessary to call both Stream..::.Close and HttpWebResponse..::.Close, but doing so does not cause an error. Failure to close the stream can cause your application to run out of connections.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Rohit Kumar</title>
		<link>http://www.longshadow.com.au/getset-windows-mobile-5-datetime-using-cnet/#comment-28</link>
		<author>Rohit Kumar</author>
		<pubDate>Wed, 23 Jul 2008 06:13:55 +0000</pubDate>
		<guid>http://www.longshadow.com.au/getset-windows-mobile-5-datetime-using-cnet/#comment-28</guid>
					<description>Hi,
     I used same code to change time of PDA having Windows Mobile 5.0 O/S,it is working well.But this code is not being supporetd by JAVA as our application is in Java and this program is in C#.NET.Finally my purpose to change PDA time having Window Mobile 5.0 is not fullfiled.My problem is that i want to change PDA time having Window Mobile 5.0 using a java program which can be called through our Java aplication.

Can someonne guide me what to do now.?? Can anyone provide me the source code in java or in othere language (so that can be called by java application)</description>
		<content:encoded><![CDATA[<p>Hi,<br />
     I used same code to change time of PDA having Windows Mobile 5.0 O/S,it is working well.But this code is not being supporetd by JAVA as our application is in Java and this program is in C#.NET.Finally my purpose to change PDA time having Window Mobile 5.0 is not fullfiled.My problem is that i want to change PDA time having Window Mobile 5.0 using a java program which can be called through our Java aplication.</p>
<p>Can someonne guide me what to do now.?? Can anyone provide me the source code in java or in othere language (so that can be called by java application)</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Coder</title>
		<link>http://www.longshadow.com.au/getset-windows-mobile-5-datetime-using-cnet/#comment-30</link>
		<author>Coder</author>
		<pubDate>Mon, 29 Sep 2008 11:13:44 +0000</pubDate>
		<guid>http://www.longshadow.com.au/getset-windows-mobile-5-datetime-using-cnet/#comment-30</guid>
					<description>Any idea how to set the timezone programmatically in c# for windows mobile


Thanks,
http://probedeep.blogspot.com/</description>
		<content:encoded><![CDATA[<p>Any idea how to set the timezone programmatically in c# for windows mobile</p>
<p>Thanks,<br />
<a href="http://probedeep.blogspot.com/" rel="nofollow">http://probedeep.blogspot.com/</a></p>
]]></content:encoded>
				</item>
</channel>
</rss>
