26 lines
830 B
C#
26 lines
830 B
C#
using System.Runtime.InteropServices;
|
|
|
|
namespace RTCSync.Utils;
|
|
|
|
public abstract class WindowsTimeUtils
|
|
{
|
|
// c# datetime set
|
|
[DllImport("kernel32.dll")]
|
|
public static extern bool SetSystemTime(ref SystemTime time);
|
|
|
|
[DllImport("kernel32.dll")]
|
|
public static extern void GetSystemTime(ref SystemTime time);
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
public struct SystemTime(DateTime dt)
|
|
{
|
|
public ushort Year = (ushort)dt.Year;
|
|
public ushort Month = (ushort)dt.Month;
|
|
public ushort DayOfWeek = (ushort)dt.DayOfWeek;
|
|
public ushort Day = (ushort)dt.Day;
|
|
public ushort Hour = (ushort)dt.Hour;
|
|
public ushort Minute = (ushort)dt.Minute;
|
|
public ushort Second = (ushort)dt.Second;
|
|
public ushort Milliseconds = (ushort)dt.Millisecond;
|
|
}
|
|
} |