设置系统时间

【勇芳软件工作室】汉化HomePreviousNext

以下示例设置系统时间。

// SetNewTime - 设置系统时间
//返回值 - 如果成功,则为TRUE,否则为FALSE
//小时 - 新小时(0-23)
//分钟 - 新的分钟(0-59)

BOOL SetNewTime(WORD hour, WORD minutes)
{
SYSTEMTIME st;
char *pc;

GetSystemTime(&st); //获取当前时间
st.wHour = hour; //调整小时数
st.wMinute = minutes; //和分钟
if (!SetSystemTime(&st)) //设置系统时间
return FALSE;
return TRUE;
}