110,571
社区成员
发帖
与我相关
我的任务
分享
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); // 写