怎么把一般的时间转化为SYSTEMTIME 怎么把一个时间,比如2009-10-10 10:10转化为SYSTEMTIME 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用COleDateTime类处理CString s = "2009-10-10 10:10";COleDateTime tT;tT.ParseDateTime(s);SYSTEMTIME st;tT.GetAsSystemTime(st); typedef struct _SYSTEMTIME { WORD wYear; WORD wMonth; WORD wDayOfWeek; WORD wDay; WORD wHour; WORD wMinute; WORD wSecond; WORD wMilliseconds;} SYSTEMTIME; bool CTime::GetAsSystemTime( SYSTEMTIME& st ) const throw( ); 然后调用CTime的GetYear,GetDay,GetMonth就可以。 你是不是要问:怎么把一个字符串时间,如:"2009-10-10 10:10" 转换为 SYSTEMTIME 结构体吧? 1楼的方法就可以了。用ParseDateTime把字符串处理重新复制即可。 嗯,1楼正解。COleDateTime类简直就是MFC界处理时间问题的终极法宝! # unsigned __int64 GetTotalMilliseconds(SYSTEMTIME st) # { # FILETIME ft; # //把SYSTEMTIME结构的时间转化为 FILETIME结构的时间 # SystemTimeToFileTime(&st,&ft); # unsigned __int64 temp; # //利用FILETIME结构计算出时间的毫秒数 # temp = unsigned __int64(ft.dwHighDateTime * 0x100000000L + ft.dwLowDateTime) / 10000L; # # //返回时间的毫秒数 # return temp ; # } 或者CTime + CTimeSpan CTimeSpan::GetTotalSecondsCall this member function to retrieve the total number of complete seconds in this CTimeSpan object. 图像匹配处理 急!急!! 接着问 一个不知如何下手解决的问题 为什么要最小化或者拖动后,窗口才会更新呢?? 回车的代码是什么 很简单的vc问题,急,希望各位帮忙解决。(在线等) 怎么样改桌面?来就有分!!!! MFC画对角线 各位高手请进:关于大数库Freelip的问题 急!我的CMOS被禁写了,放电也不行,怎么办? 0x16转成16 用CArchive类怎样实现文件的顺序读?
CString s = "2009-10-10 10:10";
COleDateTime tT;
tT.ParseDateTime(s);
SYSTEMTIME st;
tT.GetAsSystemTime(st);
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME;
SYSTEMTIME& st
) const throw( );
# {
# FILETIME ft;
# //把SYSTEMTIME结构的时间转化为 FILETIME结构的时间
# SystemTimeToFileTime(&st,&ft);
# unsigned __int64 temp;
# //利用FILETIME结构计算出时间的毫秒数
# temp = unsigned __int64(ft.dwHighDateTime * 0x100000000L + ft.dwLowDateTime) / 10000L;
#
# //返回时间的毫秒数
# return temp ;
# } 或者CTime + CTimeSpan
Call this member function to retrieve the total number of complete seconds in this CTimeSpan object.