c#中修改时间的问题
在c#中如果我要修改本地时间应该用什么类阿?
我找了半天没找到,难道非要用win32API吗?
------解决方案--------------------http://blog.csdn.net/jasonheung/archive/2005/02/01/276349.aspx
------解决方案--------------------常见的做法还是下面,
[DllImport( "Kernel32.dll ")]
private static extern bool SetSystemTime( ref SystemTime sysDate );
[DllImport( "Kernel32.dll ")]
private static extern void GetSystemTime(ref SystemTime sysDate);
public static void SetSystemDate(System.DateTime newDate)
{
SystemTime sysDate = new SystemTime();
GetSystemTime(ref sysDate);
sysDate.wYear = (ushort)newDate.Year;
sysDate.wMonth = (ushort)newDate.Month;
sysDate.wDay = (ushort)newDate.Day;
SetSystemTime(ref sysDate);
}