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 

  • 相关阅读:
    python 迭代器
    python 装饰器
    python 函数进阶
    python 函数
    python文件操作
    python 集合 深浅拷贝
    python基础之循环
    python基础之字典
    python基础之操作列表
    python基础之列表
  • 原文地址:https://www.cnblogs.com/answer/p/808403.html
Copyright © 2011-2022 走看看