Cambiar la fecha del sistema

CodeKeep C# Feed Maggio 25th, 2008

Description: Cambiar la fecha del sistema

Link: http://www.codekeep.net/snippets/1caf5b81-b062-46ea-974f-e04c87b36c41.aspx

	class Program
	{

        [System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.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;
        }

        [System.Runtime.InteropServices.DllImport("kernel32.dll", SetLastError = true)]
        private static extern bool SetLocalTime(ref SYSTEMTIME _time);

        static void Main(string[] args) {

        	SYSTEMTIME _time;

        	_time.wYear = 2000;
            _time.wMonth = 04;
            _time.wDay = 09;

            _time.wDayOfWeek = 1;

            _time.wHour = (short)DateTime.Now.Hour;
            _time.wMinute = (short)DateTime.Now.Minute;
            _time.wSecond = (short)DateTime.Now.Second;
            _time.wMilliseconds = (short)DateTime.Now.Millisecond;

            SetLocalTime(ref _time);

        }

	}

  • .NET
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Comments are closed.

Trackback URI |