zoukankan      html  css  js  c++  java
  • WinCE.NET中设置系统日期时间

     

     1 using System;
     2 using System.Runtime.InteropServices;
     3 
     4 class SysDateTime
     5 {
     6     private struct SYSTEMTIME
     7     {
     8         public ushort wYear;
     9         public ushort wMonth;
    10         public ushort wDayOfWeek;
    11         public ushort wDay;
    12         public ushort wHour;
    13         public ushort wMinute;
    14         public ushort wSecond;
    15         public ushort wMilliseconds;
    16     }
    17 
    18     [DllImport("Coredll.dll")]
    19     private static extern bool SetLocalTime(ref SYSTEMTIME lpSystemTime);
    20 
    21     public static void SetDateTime(DateTime dt)
    22     {
    23         #region Codes==========================================================
    24 
    25         SYSTEMTIME sysTime = new SYSTEMTIME();
    26         
    27         sysTime.wYear = Convert.ToUInt16(dt.Year);
    28         sysTime.wMonth = Convert.ToUInt16(dt.Month);
    29         sysTime.wDay = Convert.ToUInt16(dt.Day);
    30         sysTime.wDayOfWeek = Convert.ToUInt16(dt.DayOfWeek);
    31         sysTime.wHour = Convert.ToUInt16(dt.Hour);
    32         sysTime.wMinute = Convert.ToUInt16(dt.Minute);
    33         sysTime.wSecond = Convert.ToUInt16(dt.Second);
    34         sysTime.wMilliseconds = Convert.ToUInt16(dt.Millisecond);
    35 
    36         SetLocalTime(ref sysTime);
    37 
    38         #endregion
    39     }
    40 // class
    41 

  • 相关阅读:
    SQL 分页存储
    ubuntu下删除openjdk,改用sun jdk
    LCD 驱动的整体分析。
    关于IT行业人员吃的都是青春饭?[透彻讲解]
    【转载】I.MX25上摄像头调试总结
    wifi 移植
    函数指针的透彻分析
    关于module_param()宏 (转)
    problem with aptget update ubuntu 11.10
    YUV 格式讲解
  • 原文地址:https://www.cnblogs.com/answer/p/808403.html
Copyright © 2011-2022 走看看