Witam,
skrypt, który wklejam poniżej działał ok do dziś. zamiast zmieniać datę na 30 nie wiem dlaczego zmienia na 24 kwietnia??
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
timer1.Start();
this.WindowState = FormWindowState.Minimized;
this.ShowInTaskbar = false;
}
[StructLayout(LayoutKind.Sequential)]
private struct SystemTime
{
public ushort Year;
public ushort Month;
public ushort DayOfWeek;
public ushort Day;
public ushort Hour;
public ushort Minute;
public ushort Second;
public ushort Milliseconds;
}
[DllImport("kernel32.dll", EntryPoint = "GetSystemTime", SetLastError = true)]
private extern static void Win32GetSystemTime(ref SystemTime lpSystemTime);
[DllImport("kernel32.dll", EntryPoint = "SetSystemTime", SetLastError = true)]
[return: MarshalAsAttribute(UnmanagedType.Bool)]
private extern static bool Win32SetSystemTime(ref SystemTime lpSystemTime);
private void timer1_Tick(object sender, EventArgs e)
{
//current date is checked on each tic of the clock
DateTime currentDate = DateTime.Now;
if (currentDate.Day == 1)// && currentDate.Hour == 0)
{
SystemTime updatedTime = new SystemTime();
Win32GetSystemTime(ref updatedTime);
updatedTime.Day = 30;
updatedTime.Month = 4;
updatedTime.Year = 2011;
Win32SetSystemTime(ref updatedTime);
textBox1.Text= "Date has been successfuly changed, " + currentDate.Date;
}
else textBox1.Text += "Don`t have to change the date, " + currentDate.Date + "\r\n";
}
}