描述:
我想取得当前系统的时间(不是日期),然后将取得的时间与我预先设置的时间进行比较后做一些处理,怎么实现这些呢?
(不使用CTime类)
解决方案1:
ATL可以使用MFC的支持(包括CTime),在创建ATL工程时,选择支持MFC即可。
解决方案2: SYSTEMTIME localtime;
GetLocalTime(&localtime);
我也不知道
如果只是比较用GetTickCount()最方便了
解决方案5: SYSTEMTIME systime;
GetSystemTime(&systime);
分别取相应的域就行了
time_t t;
struct tm *ptm;
char tmstamp[21];
memset(tmstamp,0,sizeof(tmstamp));
// GetCurDateTime(tmstamp);
time(&t);
ptm = localtime(&t);
strftime(tmstamp,sizeof(tmstamp),"%Y-%m-%d %H:%M:%S",ptm);
还是用GetLocalTime函数好。GetSystemTime函数还要考虑时区的问题。
解决方案8: // Retrieves the current system date and time. The system
// time is expressed in Coordinated Universal Time (UTC).
SYSTEMTIME systime;
GetSystemTime(&systime);
CTime t = CTime::GetCurrentTime();
如果要比较时间的话,还是用CTime(或者COleDataTime)方便。