title: Change system date,time
body: <p>Hi I know this has been asked before but I need help changing system datetime in c#. While doing  a google search I found a website which suggested the following code</p>
  
  <pre><code>public struct SYSTEMTIME 
  {    
      public ushort wYear,wMonth,wDayOfWeek,wDay, wHour,wMinute,wSecond,wMilliseconds;
  }
  
  [DllImport("kernel32.dll")]
  public extern static void GetSystemTime(ref SYSTEMTIME lpSystemTime);
  
  /// &lt;param name="lpSystemTime"&gt;[in] Pointer to a SYSTEMTIME structure that
  /// contains the current system date and time.&lt;/param&gt;
  [DllImport("kernel32.dll")]
  public extern static uint SetSystemTime(ref SYSTEMTIME lpSystemTime);
  
  static void Main()
  {    
      Console.WriteLine(DateTime.Now.ToString());
      SYSTEMTIME st = new SYSTEMTIME();
      GetSystemTime(ref st);
      Console.WriteLine("Adding 1 hour...");
      st.wHour = (ushort)(st.wHour + 1 % 24);
      if (SetSystemTime(ref st) == 0)
          Console.WriteLine("FAILURE: SetSystemTime failed");
      Console.WriteLine(DateTime.Now.ToString());
      Console.WriteLine("Setting time back...");
      st.wHour = (ushort)(st.wHour - 1 % 24);
      SetSystemTime(ref st);
      Console.WriteLine(DateTime.Now.ToString());
      Console.WriteLine("Press Enter to exit");
      Console.Read();
  }
  </code></pre>
  
  <p>But when I run it in my system it shows no change in the current date/time. Should  I make any changes?<br>
  Edit: Got the message FAILURE: SetSystemTime failed when I try to run</p>