I am working on a WFA application that changes the computer date to a day ahead or a day behind, depending on the button click. Here is my code:
public Form1()
{
InitializeComponent();
currentTime.Start();
}
private void CurrentTime_Tick(object sender, EventArgs e)
{
DateTime dateTime = DateTime.Now;
this.lblTime.Text = dateTime.ToString();
}
public struct Systemtime
{
public short WDay;
}
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool SetSystemTime([In] ref Systemtime st);
private void BtnChangeDate_Click(object sender, EventArgs e)
{
Systemtime st = new Systemtime();
st.WDay++;
SetSystemTime(ref st);
}
private void BtnExit_Click(object sender, EventArgs e)
{
this.Close();
}
private void BtnPreviousDay_Click(object sender, EventArgs e)
{
Systemtime st = new Systemtime();
st.WDay--;
SetSystemTime(ref st);
}
The problem I have right now is the buttons do nothing, even if I have hard-coded values. What do I need to do to get this work correctly?