using System.Runtime.InteropServices;
public struct SYSTEMTIME
{
public short wYear;
public short wMonth;
public short wDayOfWeek;
public short wDay;
public short wHour;
public short wMinute;
public short wSecond;
public short wMilliseconds;
}
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool SetSystemTime([In] ref SYSTEMTIME st);
و یک مثال از نحوه ی استفاده :
private void Form1_Load(object sender, EventArgs e)
{
SYSTEMTIME st = new SYSTEMTIME();
st.wYear = 2003; // must be short
st.wMonth = 5;
st.wDay = 22;
st.wHour = 0;
st.wMinute = 0;
st.wSecond = 0;
SetSystemTime(ref st); // invoke this method.
}
منبع : http://www.codeguru.com/forum/archiv.../t-246724.html