TA的每日心情 | 慵懒 2016-4-21 12:07 |
---|
签到天数: 3 天 连续签到: 1 天 [LV.2]偶尔看看I 累计签到:3 天 连续签到:1 天
|
马上加入,结交更多好友,共享更多资料,让你轻松玩转电力研学社区!
您需要 登录 才可以下载或查看,没有账号?立即加入
×
1.使用CTime类
; z6 a! h8 H) g, H??CTime tm=CTime::GetCurrentTime();
0 x6 d5 J6 F* `( n7 x: b
% T6 D) m$ E$ M; f& U??CString str=tm.Format("现在时间是:%Y年%m月%d日 %X");
) u- v+ X- `* {6 Y2 L8 a MessageBox(str,NULL,MB_OK);& R9 H$ v/ T D
* g; w6 q# d! y! w2: 得到系统时间日期(使用GetLocalTime)
7 W: b$ D& c- y# `% K e) H; U??SYSTEMTIME st;
2 i6 S' O1 l% J( b??CString strDate,strTime;
( K ] j6 W4 g* h/ p, P3 f A- Q??GetLocalTime(&st);
' ^* e1 w" ], v! h??strDate.Format("%4d-%2d-%2d",st.wYear,st.wMonth,st.wDay);" d* i1 V* w1 {5 t2 n; r0 F. x* q
??strTime.Format("%2d:%2d:%2d",st.wHour,st.wMinute,st.wSecond);
( _$ u' k/ ^6 `/ z/ i8 Y5 a6 O7 J& p& G) W+ f, O
3.使用GetTickCount//获取程序运行时间 9 g2 ^. A) i: }% e W
??long t1=GetTickCount();//程序段开始前取得系统运行时间(ms)
! s% C# r! \" ?7 n/ f: d8 S f! I* R) e' ?
??。。。//程序段" c. }. f" Z! A7 ^6 ?( A
long t2=GetTickCount();//程序段结束后取得系统运行时间(ms) " G" O: @+ `% }6 [# V I! B/ N
??long t = t2-t1; //前后之差即 程序运行时间 (ms) |
|