一种方法是调用Win32 API SetSystemTime.using System.Runtime .InteropServices ;
[ StructLayout( LayoutKind.Sequential )]
public class SystemTime
{
public ushort year;
public ushort month;
public ushort dayOfWeek;
public ushort day;
public ushort hour;
public ushort minute;
public ushort second;
public ushort milliseconds;
}class MainClass
{
[ DllImport( "Kernel32.dll" )]
public static extern void GetSystemTime( [In,Out] SystemTime st ); [ DllImport( "Kernel32.dll" )]
public static extern bool SetSystemTime( [In,Out] SystemTime st );
public static void Main(string[] args)
{
SystemTime st=new SystemTime ();
GetSystemTime(st); st.year +=1;
bool result=SetSystemTime(st);
}
}
微软亚洲技术中心 VC技术支持本贴子仅供CSDN的用户作为参考信息使用。其内容不具备任何法律保障。您需要考虑到并承担使用此信息可能带来的风险。具体事项可参见使用条款 (http://www.csdn.net/microsoft/terms.shtm)。
[ StructLayout( LayoutKind.Sequential )]
public class SystemTime
{
public ushort year;
public ushort month;
public ushort dayOfWeek;
public ushort day;
public ushort hour;
public ushort minute;
public ushort second;
public ushort milliseconds;
}class MainClass
{
[ DllImport( "Kernel32.dll" )]
public static extern void GetSystemTime( [In,Out] SystemTime st ); [ DllImport( "Kernel32.dll" )]
public static extern bool SetSystemTime( [In,Out] SystemTime st );
public static void Main(string[] args)
{
SystemTime st=new SystemTime ();
GetSystemTime(st); st.year +=1;
bool result=SetSystemTime(st);
}
}
微软亚洲技术中心 VC技术支持本贴子仅供CSDN的用户作为参考信息使用。其内容不具备任何法律保障。您需要考虑到并承担使用此信息可能带来的风险。具体事项可参见使用条款 (http://www.csdn.net/microsoft/terms.shtm)。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货