2012.10.13 周六

来源:互联网 发布:怎么查询80端口被占用 编辑:程序博客网 时间:2024/05/01 21:05

安装VS2010的MSDN

参考链接:http://www.cnblogs.com/lyj/archive/2010/06/01/vs2010-setup-zh-cn-msdn.html

打开Microsoft Visual Studio 2010开始菜单里Visual Studio Tools里的Manage Help Settings - ENU。

我们从磁盘安装内容,选择cn_visual_studio_2010_ultimate_x86_dvd_532347.iso里面ProductDocumentation文件夹的HelpContentSetup.msha文件。如果你没有中文版iso也可以选择联机安装内容,在线安装MSDN中英文文档。

VC获取系统时间和运行时间

1.使用CTime类

CString str;
 CTime tm;
 tm=CTime::GetCurrentTime(); //获取系统时间
 str=tm.Format("现在时间是%Y年%m月%d日  %X");

2: 得到系统时间日期(使用GetLocalTime)

SYSTEMTIME st;
CString strDate,strTime;
GetLocalTime(&st);
strDate.Format("%4d-%2d-%2d",st.wYear,st.wMonth,st.wDay);
strTime.Format("%2d:%2d:%2d",st.wHour,st.wMinute,st.wSecond);

3.使用GetTickCount
//获取程序运行时间
 long t1=GetTickCount();//程序段开始前取得系统运行时间(ms)
 Sleep(500);
 long t2=GetTickCount();();//程序段结束后取得系统运行时间(ms)
 str.Format("time:%dms",t2-t1);//前后之差即 程序运行时间
 AfxMessageBox(str);
//获取系统运行时间
long t=GetTickCount();
 CString str,str1;
 str1.Format("系统已运行 %d时",t/3600000);
 str=str1;
 t%=3600000;
 str1.Format("%d分",t/60000);
 str+=str1;
 t%=60000;
 str1.Format("%d秒",t/1000);
 str+=str1;
 AfxMessageBox(str);

4

 time_t m = time(NULL);
 t= localtime( &m );

获得1900年到现在,得时间间隔,最小秒。

tm_sec

Seconds after minute (0 – 59)

tm_min

Minutes after hour (0 – 59)

tm_hour

Hours after midnight (0 – 23)

tm_mday

Day of month (1 – 31)

tm_mon

Month (0 – 11; January = 0)

tm_year

Year (current year minus 1900)

tm_wday

Day of week (0 – 6; Sunday = 0)

tm_yday

Day of year (0 – 365; January 1 = 0)

tm_isdst //夏令时

Positive value if daylight saving time is in effect; 0 if daylight saving time is not in effect; negative value if status of daylight saving time is unknown. The C run-time library assumes the United States’s rules for implementing the calculation of Daylight Saving Time (DST).

5,gmtime 同localtime但显示的是世界时间



原创粉丝点击