欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

電腦開(kāi)機(jī)時(shí)間的計(jì)算代碼

 更新時(shí)間:2013年05月17日 17:09:18   作者:  
這幾天我琢磨著一件事,那就是怎么計(jì)算我的PC從開(kāi)機(jī)到現(xiàn)在的總時(shí)間。終于,看看這個(gè)函數(shù):GetTickCount();

函數(shù)功能:GetTickCount返回(retrieve)從操作系統(tǒng)啟動(dòng)到現(xiàn)在所經(jīng)過(guò)(elapsed)的毫秒數(shù),它的返回值是DWORD.

知道了這個(gè),這個(gè)程序也就不是什么難事了。。。

CODE:

復(fù)制代碼 代碼如下:

#include <stdlib.h>
 #include <time.h>
 #include <windows.h>
 #include <stdio.h>

 typedef struct node
 {
     int h;
     int m;
     int s;
 }
 *PTime;

 void sleep(long wait);

 void gettime();

 int main()
 {
     PTime times;
     int flag = 1;
     char time[128];
     do
     {
         _strtime(time); // Gets the current system time (do not include the date)
         system("cls"); // clear screen
         printf("OS time: %s\n",time);

         gettime(times); // call gettime()
         sleep(1000); // sleep 1 second

         printf("已開(kāi)機(jī)時(shí)間: %02d小時(shí)%02d分%02d秒\n", times->h, times->m, times->s);
     }while(flag); // always cycle

     return 0;
 }

 void sleep(long wait)
 {
     long goal; // define total time
     goal = wait + clock();
     while(goal > clock());
 }

 PTime gettime(PTime T)
 {
     int i = GetTickCount();
     T->h = (i / 1000) / 3600;
     T->m = (i / 1000) / 60 - T->h * 60;
     T->s = (i / 1000) - T->h * 3600 - T->m * 60;
     return T;
 }

相關(guān)文章

最新評(píng)論