PDA

View Full Version : تغییر ساعت سیستم از طریق کد نویسی



ssmehizadeh
شنبه 17 آبان 1393, 12:51 عصر
با سلام

با دستورات زیر قصد دارم تاریخ و ساعت سیستم رو تغییر بدم

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);


SYSTEMTIME st = new SYSTEMTIME();
st.wYear = 2003; // must be short
st.wMonth = 5;
st.wDay = 22;
st.wHour = 9;
st.wMinute = 7;
st.wSecond = 7;
SetSystemTime(ref st); // invoke this method

تاریخ به درست تغییر می کنه ولی ساعت به 9:7:7 تغییر نمی کنه ..

مشکلم چیه .

Amir4317
شنبه 17 آبان 1393, 21:28 عصر
یه سری بزن به استک اور stackoverflow (http://stackoverflow.com/questions/650849/change-system-date-programatically) : change system date programatically

مقادر رو به ushort تغییر بده