none
如何用程式來設定pda上面的時間 RRS feed

解答


  •       private void setSystemTime(object sender, System.EventArgs e)
          {
                 
                CoreDll.SYSTEMTIME st = new CoreDll.SYSTEMTIME();
                st.wYear   = (ushort)t.Year;
                st.wMonth  = (ushort)t.Month;
                st.wDay    = (ushort)t.Day;
                st.wHour   = (ushort)t.Hour;
                st.wMinute = (ushort)t.Minute;
                st.wSecond = (ushort)t.Second;

                if ( CoreDll.SetSystemTime(ref st) == 0 )
                {
                   throw new Exception("Error setting system date and time");
                }
                else
                {
                   label2.Text = "System date and time set to\n" + t.ToString();
                }
            }


       public class CoreDll
       {
          public struct SYSTEMTIME
          {
             public ushort wYear;
             public ushort wMonth;
             public ushort wDayOfWeek;
             public ushort wDay;
             public ushort wHour;
             public ushort wMinute;
             public ushort wSecond;
             public ushort wMilliseconds;
          }

          [DllImport("coredll.dll")]
          public extern static uint SetSystemTime(ref SYSTEMTIME lpSystemTime);
       }

    2007年9月29日 下午 02:58

所有回覆


  •       private void setSystemTime(object sender, System.EventArgs e)
          {
                 
                CoreDll.SYSTEMTIME st = new CoreDll.SYSTEMTIME();
                st.wYear   = (ushort)t.Year;
                st.wMonth  = (ushort)t.Month;
                st.wDay    = (ushort)t.Day;
                st.wHour   = (ushort)t.Hour;
                st.wMinute = (ushort)t.Minute;
                st.wSecond = (ushort)t.Second;

                if ( CoreDll.SetSystemTime(ref st) == 0 )
                {
                   throw new Exception("Error setting system date and time");
                }
                else
                {
                   label2.Text = "System date and time set to\n" + t.ToString();
                }
            }


       public class CoreDll
       {
          public struct SYSTEMTIME
          {
             public ushort wYear;
             public ushort wMonth;
             public ushort wDayOfWeek;
             public ushort wDay;
             public ushort wHour;
             public ushort wMinute;
             public ushort wSecond;
             public ushort wMilliseconds;
          }

          [DllImport("coredll.dll")]
          public extern static uint SetSystemTime(ref SYSTEMTIME lpSystemTime);
       }

    2007年9月29日 下午 02:58
  • 感恩,是否有更簡單的方法或是vb code

     

    2007年9月29日 下午 03:09