当前位置:首页 » 操作系统 » 毫秒源码

毫秒源码

发布时间: 2023-08-05 17:07:46

㈠ 求C++获取系统时间源代码,精确到毫秒

#include <iostream>
#include <windows.h>

using namespace std;

void main()
{

SYSTEMTIME time;//时间结构声明,这个结构是系统的,
GetSystemTime( &time );//调用获取系统时间api.
//GetLocalTime();这个函数是获取本地时间api
char* t_y;
char* t_m;
char* t_h;
char* t_Min;
char* t_s;
char* t_Mi;
char* t_d;
char* t_w;

SYSTEMTIME time;//时间结构声明,这个结构是系统的,
GetSystemTime( &time );//调用获取系统时间api.
sprintf(t_y, "%d", time.wYear);//将年份格式输出到t_y变量中
sprintf(t_m, "%d", time.wMonth);
sprintf(t_w, "%d", time.wDayOfWeek);
sprintf(t_d, "%d", time.wDay);
sprintf(t_h, "%d", time.wHour);
sprintf(t_Min, "%d", time.wMinute);
sprintf(t_s, "%d", time.wSecond);
sprintf(t_Mi, "%d", time.wMilliseconds);
printf("%s,%s,%s,%s,%s,%s,%s,%s",
time.wYear,
time.wMonth,
time.wDayOfWeek,
time.wDay,
time.wHour,
time.wMinute,
time.wSecond,
time.wMilliseconds);

}
/***
SYSTEM 结构成员如下:
SYSTEMTIME STRUCT
{
WORD wYear ; 年
WORD wMonth ;月
WORD wDayOfWeek ;星期,0=星期日,1=星期一...
WORD wDay ;日
WORD wHour ;时
WORD wMinute ;分
WORD wSecond ;秒
WORD wMilliseconds ;毫秒
}SYSTEMTIME ENDS
//***/

㈡ 用flash as3.0制作一个10分钟倒计时(精确到毫秒)!求源代码~~

这种样子的,行吗?

㈢ 求几个比较有趣,简单的C语言源代码 小白自己敲着练一下手感

最简单的模拟计时器:

#include<stdio.h>

#include<conio.h>

#include<windows.h>

int m=0,s=0,ms=0; //m是分 s是秒 ms是毫秒

//以下是5个自编函数

void csh( ); //初始化界面

void yinc(int x,int y); //隐藏光标的函数(y值设为0就会隐藏)

void jishi( ); //计时器运行(每100毫秒变化一次)

void Color (short x, short y); //设定颜色的函数(y设为0就是黑底)

void gtxy (int x, int y); //控制光标位置的函数

int main( ) //主函数

{ csh( );

getch( );

while(1)

{ jishi( );

Sleep(100); //间隔100毫秒

if( kbhit( ) )break; //有键按下就退出循环

}

return 0;

}

void csh( ) //初始化界面

{Color(14,0); //设定淡黄字配黑底

printf(“ 计时器”);

Color(10,0); //设定淡绿字配黑底

printf(" ┌───────────┐");

printf(" │ │");

printf(" └───────────┘");

gtxy(10,4); //光标到屏幕第10列4行处输出

Color(7,0); //恢复白字黑底

printf(" 00:00:00 ");

yinc(1,0 ); //隐藏光标(yinc代表隐藏)

return;

}

void jishi( ) //计时器运行

{ms+=1;

if(ms==10){s+=1;ms=0;}

if(s==60){m+=1;s=0;}

gtxy(10,4);

Color(9,0); //设定淡蓝字配黑底

if(m>9) printf(" %d:",m);

else printf(" 0%d:",m);

Color(14,0); //设定淡黄字配黑底

if(s>9) printf("%d:",s);

else printf("0%d:",s);

Color(12,0); //设定淡红字配黑底

printf("0%d",ms);

}

void gtxy (int x, int y) //控制光标位置的函数

{ COORD pos;

pos.X = x;

pos.Y = y;

SetConsoleCursorPosition ( GetStdHandle (STD_OUTPUT_HANDLE), pos );

}

void Color (short ForeColor= 7, short BackGroundColor= 0) //设定颜色的函数

{ HANDLE handle = GetStdHandle ( STD_OUTPUT_HANDLE );

SetConsoleTextAttribute ( handle, ForeColor + BackGroundColor * 0x10 );

}

void yinc(int x,int y) //隐藏光标的设置(gb代表光标)

{ CONSOLE_CURSOR_INFO gb={x,y}; //x为1-100,y为0就隐藏光标

SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &gb);

}

热点内容
米思齐编译失败怎么看 发布:2025-03-12 19:26:27 浏览:847
sql语句notexists 发布:2025-03-12 19:16:11 浏览:59
快手安卓版如何玩 发布:2025-03-12 19:15:26 浏览:35
scott数据库 发布:2025-03-12 19:15:19 浏览:872
rom服务器是什么 发布:2025-03-12 19:10:27 浏览:61
我给你改个密码叫什么 发布:2025-03-12 19:09:32 浏览:673
宽带密码在手机上如何更改 发布:2025-03-12 19:07:52 浏览:115
python离线安装pip 发布:2025-03-12 19:06:18 浏览:28
超时代加密视频破解 发布:2025-03-12 19:03:10 浏览:95
服务器怎么做游戏 发布:2025-03-12 18:57:30 浏览:615