码迷,mamicode.com
首页 > 其他好文 > 详细

修改系统时间

时间:2015-09-30 10:52:29      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:

//imports SetLocalTime function from kernel32.dll 
[DllImport("kernel32.dll", SetLastError=true)] 
public static extern int SetLocalTime (ref SystemTime lpSystemTime); 

//struct for date/time apis 
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; 
} 

// And then set up a structure with the required properties and call the api from code: 

SystemTime systNew = new SystemTime(); 

// 设置属性 
systNew.wDay = 1; 
systNew.wMonth = 1; 
systNew.wYear = 2004; 
systNew.wHour = 9; 
systNew.wMinute = 0; 
systNew.wSecond = 0; 

// 调用API,更新系统时间 
SetLocalTime(ref systNew);

 

修改系统时间

标签:

原文地址:http://www.cnblogs.com/junhuang/p/4848423.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!