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 

  • 相关阅读:
    放大图 带回弹效果
    用recyclerview实现对话(通过接口实现)
    java 问号表达式
    recyclerview的使用
    我遇到的报错信息整理
    横竖屏切换
    NOIP 2017提高组自测 奶酪
    小蝌蚪找妈妈 牛客
    牛客练习赛50 C tokitsukaze and Soldier
    洛谷P1630 求和
  • 原文地址:https://www.cnblogs.com/answer/p/808403.html
Copyright © 2011-2022 走看看