public static SYSTEMTIME FromDateTime(DateTime dateTime) { var st = new SYSTEMTIME(); st.wYear = (ushort)dateTime.Year; st.wMonth = (ushort)dateTime.Month; st.wDayOfWeek = (ushort)dateTime.DayOfWeek; st.wDay = (ushort)dateTime.Day; st.wHour = (ushort)dateTime.Hour; st.wMinute = (ushort)dateTime.Minute; st.wSecond = (ushort)dateTime.Second; st.wMilliseconds = (ushort)dateTime.Millisecond; return st; }
public static extern bool SetSystemTime(ref SYSTEMTIME time);
public static extern bool SetLocalTime(ref SYSTEMTIME time);
public static extern void GetSystemTime(ref SYSTEMTIME time);
public static extern void GetLocalTime(ref SYSTEMTIME time);