这是我改变系统时间的代码:
(我想在我的 vps - windows server 2008 - r2 )中使用它们
[StructLayout(LayoutKind.Sequential)]
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(ref SYSTEMTIME theDateTime);
private void button1_Click(object sender, EventArgs e)
{
DateTime now = DateTime.Now;
SYSTEMTIME st = new SYSTEMTIME();
st.wYear = short.Parse(now.Year.ToString()); // must be short
st.wMonth = short.Parse(now.Month.ToString());
st.wDay = short.Parse(now.Day.ToString());
st.wDayOfWeek = short.Parse(((int)now.DayOfWeek).ToString());
st.wHour = 5;
st.wMinute = 20;
st.wSecond = 30;
st.wMilliseconds = 0;
bool ret_val = SetSystemTime(ref st); // invoke this method.
}
但我在这些代码之后的时间是:6:20 AM 有什么问题,我该如何解决?
编辑:
我的UTC是:(UTC)都柏林,爱丁堡,里斯本,伦敦