How to change System time?

  • Thread starter Thread starter Srinivas Kollipara
  • Start date Start date
S

Srinivas Kollipara

Hello all,
i have a problem to change system time programatically in C#. Can Any one
help me with that.
thanks
 
This is what you need :)

----------------------------

[DllImport("kernel32.dll")]
static extern bool SetLocalTime(ref SYSTEMTIME time);

[StructLayoutAttribute(LayoutKind.Sequential)]
private struct SYSTEMTIME
{
public short year;
public short month;
public short dayOfWeek;
public short day;
public short hour;
public short minute;
public short second;
public short milliseconds;
}

SYSTEMTIME st;

st.year = ...
st.month = ...
st.dayOfWeek =...
st.day = ...
st.hour = ...
st.minute = ...
st.second = ...
st.milliseconds = ...

SetLocalTime(ref st);
 
Back
Top