您的位置:首页 > 编程语言 > C语言/C++

MFC中程序的延时

2016-07-14 21:18 477 查看
在执行程序的过程中,可以根据不同的需求进行不同的延时操作,这里介绍两种方法,希望对大家有用!

1.Sleep(t);t的单位是毫秒;

但是在执行的过程中,整个程序会挂起来,停止执行;

2.timeGetTime()函数;

该函数以毫秒统计系统的时间,该时间为从系统开启算起的运行时间;

该函数在头文件<MMsystem.h>中;

程序如下:

#include <stdafx.h>  

#include <Windows.h>  

#include <MMSystem.h>  

#include <iostream>  

  

using namespace std;  

  

#pragma comment(lib, "winmm.lib")  

  

void main(){  

    DWORD timeBegin = timeGetTime();  

    DWORD timeEnd = 0;  

    do   

    {  

        timeEnd = timeGetTime();  

        cout<< timeEnd <<endl;  

    } while (timeEnd - timeBegin <= 100);  

    getchar();  



更多的延时方法见博客:http://www.cppblog.com/sunraiing9/archive/2006/12/14/16415.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  系统延时 vc++