TA的每日心情 | 慵懒 2016-4-21 12:07 |
|---|
签到天数: 3 天 连续签到: 1 天 [LV.2]偶尔看看I 累计签到:3 天 连续签到:1 天
|
马上加入,结交更多好友,共享更多资料,让你轻松玩转电力研学社区!
您需要 登录 才可以下载或查看,没有账号?立即加入
×
1.使用CTime类
* H2 I$ ^/ H- T6 G( a* F??CTime tm=CTime::GetCurrentTime();
U" M( k( Q* P) l6 n
" B6 \3 y; u' y# i. v7 p! A1 @??CString str=tm.Format("现在时间是:%Y年%m月%d日 %X");# j& K4 @2 l" f4 o; p
MessageBox(str,NULL,MB_OK);3 ?* F% ~# j6 h# L4 M
; M" X: ~- |1 n4 H$ [2: 得到系统时间日期(使用GetLocalTime): D5 m; Q2 d. Y, a7 [! m$ J# D
??SYSTEMTIME st;' B# j r* U. H! {8 p+ P4 H+ M
??CString strDate,strTime;
' f* L" V3 G" `$ ]: ]??GetLocalTime(&st);
5 K% P/ O: w( @! f??strDate.Format("%4d-%2d-%2d",st.wYear,st.wMonth,st.wDay);. c8 A$ k& v% L( \- M" d2 v1 S. B1 F
??strTime.Format("%2d:%2d:%2d",st.wHour,st.wMinute,st.wSecond);$ @2 K1 _' {6 f; P* ]. l( p
+ O }+ A! l9 S, g2 E6 e1 W2 P, m, [3.使用GetTickCount//获取程序运行时间 + C& o; Y3 a* W4 S {
??long t1=GetTickCount();//程序段开始前取得系统运行时间(ms)
2 S1 M1 U3 q& R1 _/ O2 I' q8 P4 }) E l
??。。。//程序段7 a3 q. P1 G, I& i# i
long t2=GetTickCount();//程序段结束后取得系统运行时间(ms)
) x: I( |4 O' G- X1 k3 p??long t = t2-t1; //前后之差即 程序运行时间 (ms) |
|