请教各位大侠:如何用VC程序修改系统时间?
有没有可以调用的库函数? 问题点数:10、回复次数:7Top
1 楼lcglf1978(骑士)回复于 2003-09-02 16:18:41 得分 2
先定义一个systemtime t;
改变结构t中的时分秒等,然后调用下面的这个函数
BOOL SetSystemTime(
CONST SYSTEMTIME *lpSystemTime // address of system time to set
)
Top
2 楼jialh7302()回复于 2003-09-29 09:41:45 得分 2
typedef struct _SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME, *PSYSTEMTIME;
BOOL SetSystemTime(
CONST SYSTEMTIME *lpSystemTime // system time
);
Top
3 楼zhongjian(zhongjian)回复于 2003-10-08 17:59:08 得分 0
怎样在vc程序中调用控制面板程序(.cpl)Top
4 楼jussoo(cuteboy)回复于 2003-10-08 22:02:16 得分 0
Up
Top
5 楼yanw0212(爱家的男人)回复于 2004-02-16 16:00:18 得分 2
// SetNewTime - sets system time
// Return value - TRUE if successful, FALSE otherwise
// hour - new hour (0-23)
// minutes - new minutes (0-59)
BOOL SetNewTime(WORD hour, WORD minutes)
{
SYSTEMTIME st;
char *pc;
GetSystemTime(&st); // gets current time
st.wHour = hour; // adjusts hours
st.wMinute = minutes; // and minutes
if (!SetSystemTime(&st)) // sets system time
return FALSE;
return TRUE;
}
Top
6 楼zhaohuiguang(晓晓)回复于 2004-02-16 16:10:42 得分 2
用
SYSTEMTIME tTime;
GetSystemTime(&tTime);
//修改 tTime的成员,如:
tTime.wHour = 12;
//然后
SetSystemTime(&tTime);
能正确地设置系统时间。Top
7 楼kongyunzhongque(云雀)回复于 2004-02-16 16:53:32 得分 2
调出系统时间设置对话框:
WinExec("Rundll32 shell32.dll,Control_RunDLL timedate.cpl",SW_SHOW);
如果用代码修改的话,就用上面几位所说的办法Top



