using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text; namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
SystemTime MySystemTime = new SystemTime();
SetSystemDateTime.GetLocalTime(MySystemTime);
MySystemTime.wYear = 2017;
MySystemTime.wMonth = 2;
MySystemTime.wDay = 3;
MySystemTime.wHour = 12;
MySystemTime.wMinute = 45;
MySystemTime.wSecond = 31;
MySystemTime.wMiliseconds = 678;
SetSystemDateTime.SetLocalTime(MySystemTime);
}
} [StructLayout(LayoutKind.Sequential)]
public struct SystemTime
{
public ushort wYear;
public ushort wMonth;
public ushort wDayOfWeek;
public ushort wDay;
public ushort wHour;
public ushort wMinute;
public ushort wSecond;
public ushort wMiliseconds;
}
public class SetSystemDateTime
{
[DllImportAttribute("Kernel32.dll")] public static extern void GetLocalTime(SystemTime st); [DllImportAttribute("Kernel32.dll")] public static extern void SetLocalTime(SystemTime st);
}
}