您的位置:首页 > 理论基础

读取和修改计算机系统时间

2008-01-08 13:20 267 查看

using System.Runtime.InteropServices;




[StructLayout(LayoutKind.Sequential)]


public class SystemTime




...{


    public ushort year;


    public ushort month;


    public ushort dayOfWeek;


    public ushort day;


    public ushort hour;


    public ushort minute;


    public ushort second;


    public ushort milliseconds;


}


[DllImport("Kernel32.dll")]


public static extern void GetSystemTime([In, Out] SystemTime st);




[DllImport("Kernel32.dll")]


public static extern bool SetSystemTime([In, Out] SystemTime st);




SystemTime vSystemTime = new SystemTime();


GetSystemTime(vSystemTime); // 读


vSystemTime.year += 1;


SetSystemTime(vSystemTime); // 写

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  class