public struct SYSTEMTIME { public short wYear; public short wMonth; public short wDayOfWeek; public short wDay; public short wHour; public short wMinute; public short wSecond; public short wMilliseconds; } [DllImport("kernel32.dll", SetLastError = true)] public static extern void SetSystemTime(ref SYSTEMTIME st); public void SetSystemDateTime(DateTime ServerDateTime) { ServerDateTime = ServerDateTime.AddHours(-5).AddMinutes(-30); SYSTEMTIME st = new SYSTEMTIME(); st.wYear = (short)ServerDateTime.Year; // must be short st.wMonth = (short)ServerDateTime.Month; st.wDay = (short)ServerDateTime.Day; st.wHour = (short)ServerDateTime.Hour; st.wMinute = (short)ServerDateTime.Minute; st.wSecond = (short)ServerDateTime.Second; st.wMilliseconds = (short)ServerDateTime.Millisecond; SetSystemTime(ref st); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)