Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Set system time using C# on windows 7
- [StructLayout(LayoutKind.Sequential)]
- 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 bool SetSystemTime( [In] ref SYSTEMTIME st );
- SYSTEMTIME st = new SYSTEMTIME();
- st.wYear = 2003; // must be short
- st.wMonth = 5;
- st.wDay = 22;
- st.wHour = 0;
- st.wMinute = 0;
- st.wSecond = 0;
- SetSystemTime(ref st);
Add Comment
Please, Sign In to add comment