序号:26101 发表者:流诊圆 发表日期:2002-12-28 21:09:49
主题:如何修改系统时间
内容:不知道在BC或者TC下如何修改系统时间。
返回上页访问论坛
回复者:tjhe 回复日期:2002-12-28 21:56:40
内容:如果是WINDOWS程序BOOL SetSystemTime( CONST SYSTEMTIME *lpSystemTime );不是,可用函数:void settime(struct time *timep); //dos.h
返回上页访问论坛
回复者:流诊圆 回复日期:2002-12-28 23:14:25
内容:偶对这个函数不大熟呀!帮忙帮到底吧。举个例子让偶看看吧。
返回上页访问论坛
答案被接受回复者:tjhe 回复日期:2002-12-28 23:21:59
内容://tc2.0 dos.h中struct time { unsigned char ti_min; /* Minutes */ unsigned char ti_hour; /* Hours */ unsigned char ti_hund; /* Hundredths of seconds */ unsigned char ti_sec; /* Seconds */};struct date { int da_year; /* Year - 1980 */ char da_day; /* Day of the month */ char da_mon; /* Month (1 = Jan) */};void _Cdecl setdate (struct date *datep);void _Cdecl settime (struct time *timep);#include <stdio.h> #include <dos.h> int main(void) { struct time t; gettime(&t); printf("The current minute is: %d\n", t.ti_min); printf("The current hour is: %d\n", t.ti_hour); printf("The current hundredth of a second is: %d\n", t.ti_hund); printf("The current second is: %d\n", t.ti_sec); /* Add one to the minutes struct element and then call settime */ t.ti_min++; settime(&t); return 0; } #include <stdio.h> #include <process.h> #include <dos.h> int main(void) { struct date reset; struct date save_date; getdate(&save_date); printf("Original date:\n"); system("date"); reset.da_year = 2001; reset.da_day = 1; reset.da_mon = 1; setdate(&reset); printf("Date after setting:\n"); system("date"); setdate(&save_date); printf("Back to original date:\n"); system("date"); return 0; } //typedef struct _SYSTEMTIME { // st WORD wYear; WORD wMonth; WORD wDayOfWeek; WORD wDay; WORD wHour; WORD wMinute; WORD wSecond; WORD wMilliseconds; } SYSTEMTIME; SetSystemTime(........)
返回上页访问论坛
回复者:流诊圆 回复日期:2002-12-29 15:28:00
内容:very good !thank you!
返回上页访问论坛