Home
Manage Your Code
Snippet: Cambiar la fecha del sistema (C#)
Title: Cambiar la fecha del sistema Language: C#
Description: Cambiar la fecha del sistema Views: 93
Author: gabinortega cespedes Date Added: 5/24/2008
Copy Code  
1	class Program
2	{
3
4        [System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
5        public struct SYSTEMTIME
6        {
7            public short wYear;
8            public short wMonth;
9            public short wDayOfWeek;
10            public short wDay;
11            public short wHour;
12            public short wMinute;
13            public short wSecond;
14            public short wMilliseconds;
15        }
16
17        [System.Runtime.InteropServices.DllImport("kernel32.dll", SetLastError = true)]
18        private static extern bool SetLocalTime(ref SYSTEMTIME _time);
19
20
21        static void Main(string[] args) {
22        	
23        	SYSTEMTIME _time;
24
25        	_time.wYear = 2000;
26            _time.wMonth = 04;
27            _time.wDay = 09;
28
29            _time.wDayOfWeek = 1;
30
31            _time.wHour = (short)DateTime.Now.Hour;
32            _time.wMinute = (short)DateTime.Now.Minute;
33            _time.wSecond = (short)DateTime.Now.Second;
34            _time.wMilliseconds = (short)DateTime.Now.Millisecond;
35            
36            SetLocalTime(ref _time);
37
38            
39        }
40
41	}
42