设置系统时间问题?
okbutton_Click 单击之后,我想把Integer 类型的YearTemp MonthTemp DayTemp
HourTemp MinTemp SecTemp的值设置成当前系统的时间,api函数我比较陌生,倘若不用api怎样来处理,请大家给点帮助?
[解决办法]
参考如下的代码:
public struct SystemTime
{
public ushort wYear;
public ushort wMonth;
public ushort wDayOfWeek;
public ushort wDay;
public ushort wHour;
public ushort wMinute;
public ushort wSecond;
public ushort wMiliseconds;
}
[DllImport( "Kernel32.dll ")]
public static extern bool SetSystemTime(ref SystemTime sysTime);
private void button1_Click(object sender, EventArgs e)
{
SystemTime time = new SystemTime();
time.wYear = 2007;
time.wMonth = 07;
time.wDay = 20;
time.wDayOfWeek = 1;
time.wHour = 14 - 8;
time.wMinute = 22;
time.wSecond = 50;
time.wMiliseconds = 0;
SetSystemTime(ref time);
}
[解决办法]
我想把Integer 类型的YearTemp MonthTemp DayTemp
HourTemp MinTemp SecTemp的值设置成当前系统的时间,api函数我比较陌生
_________________________________________________________
这有必要用API吗?
Dim YearTemp As Integer,MonthTemp As Integer,DayTemp As Integer
YearTemp = Now.Year
MonthTemp = Now.Month
DayTemp = Now.Day