- 浏览: 4333430 次
- 性别:
- 来自: 湛江
博客专栏
-
SQLite源码剖析
浏览量:79428
-
WIN32汇编语言学习应用...
浏览量:68376
-
神奇的perl
浏览量:101498
-
lucene等搜索引擎解析...
浏览量:281206
-
深入lucene3.5源码...
浏览量:14608
-
VB.NET并行与分布式编...
浏览量:65559
-
silverlight 5...
浏览量:31320
-
算法下午茶系列
浏览量:45206
文章分类
最新评论
-
yoyo837:
counters15 写道目前只支持IE吗?插件的东西是跨浏览 ...
Silverlight 5 轻松开启绚丽的网页3D世界 -
shuiyunbing:
直接在前台导出方式:excel中的单元格样式怎么处理,比如某行 ...
Flex导出Excel -
di1984HIT:
写的很好~
lucene入门-索引网页 -
rjguanwen:
在win7 64位操作系统下,pygtk的Entry无法输入怎 ...
pygtk-entry -
ldl_xz:
http://www.9958.pw/post/php_exc ...
PHPExcel常用方法汇总(转载)
The QueryPerformanceFrequency function retrieves thefrequency of the high-resolution performance counter, if oneexists. The frequency cannot change while the system isrunning.
Syntax
BOOL QueryPerformanceFrequency( LARGE_INTEGER *lpFrequency);
Parameters
lpFrequency [out] Pointer to a variable that receives thecurrent performance-counter frequency, in counts per second. If theinstalled hardware does not support a high-resolution performancecounter, this parameter can be zero.
Return Value
If the installed hardware supports a high-resolution performancecounter, the return value is nonzero.
If the function fails, the return value is zero. To get extendederror information, call GetLastError. Forexample, if the installed hardware does not support ahigh-resolution performance counter, the function fails.
Function Information
Minimum DLL Version kernel32.dll Header Declared in Winbase.h, includeWindows.h Import library Kernel32.lib Minimum operating systems Windows 95, WindowsNT 3.1 Unicode Implemented as Unicode version.
See Also
Timers Overview,QueryPerformanceCounter
QueryPerformanceCounter返回当前频率值。
二.代码例子
////////////////////////////////////////////////////////////////////
#include "CTimer.h"
//---------------------- default constructor------------------------------
//
//-------------------------------------------------------------------------
CTimer::CTimer(): m_FPS(0),
m_TimeElapsed(0.0f),
m_FrameTime(0),
m_LastTime(0),
m_PerfCountFreq(0)
{
//how many ticks per sec do we get
//返回系统每秒频率
QueryPerformanceFrequency( (LARGE_INTEGER*)&m_PerfCountFreq);
// m_TimeScale 为每频率占用的秒数
m_TimeScale = 1.0f/m_PerfCountFreq;
}
//---------------------- constructor-------------------------------------
//
// use to specify FPS
//
//-------------------------------------------------------------------------
CTimer::CTimer(float fps): m_FPS(fps),
m_TimeElapsed(0.0f),
m_LastTime(0),
m_PerfCountFreq(0)
{
//how many ticks per sec do we get
//返回系统每秒频率
QueryPerformanceFrequency( (LARGE_INTEGER*)&m_PerfCountFreq);
m_TimeScale = 1.0f/m_PerfCountFreq;
//calculate ticks per frame
//m_FPS为你希望系统每秒多少频率
//m_FrameTime为你设定的每频率相当于系统实际多少频率.可理解为每频率多少时间
m_FrameTime = (LONGLONG)(m_PerfCountFreq /m_FPS);
}
//------------------------Start()-----------------------------------------
//
// call this immediately prior to game loop.Starts the timer (obviously!)
//启动定时器
//--------------------------------------------------------------------------
void CTimer::Start()
{
//get the time
QueryPerformanceCounter( (LARGE_INTEGER*)&m_LastTime);
//update time to render next frame
//m_LastTime为定时开始前的时间
// m_NextTime为下次定时到了的时间.
m_NextTime = m_LastTime + m_FrameTime;
return;
}
//-------------------------ReadyForNextFrame()-------------------------------
//
// returns true if it is time to move on to thenext frame step. To be used if
// FPS is set.
//检测定时是否已经到了
//----------------------------------------------------------------------------
bool CTimer::ReadyForNextFrame()
{
if (!m_FPS)
{
MessageBox(NULL, "No FPS set in timer", "Doh!", 0);
returnfalse;
}
QueryPerformanceCounter( (LARGE_INTEGER*)&m_CurrentTime);
if (m_CurrentTime >m_NextTime)
{//定时到了
// m_TimeElapsed为本次定时用了多少秒
//更新定时开始前的时间 m_LastTime
m_TimeElapsed =(m_CurrentTime - m_LastTime) * m_TimeScale;
m_LastTime =m_CurrentTime;
//update time to render nextframe
m_NextTime = m_CurrentTime +m_FrameTime;
return true;
}
return false;
}
//--------------------------- TimeElapsed--------------------------------
//
// returns time elapsed since last call to thisfunction. Use in main
// when calculations are to be based on dt.
//
//-------------------------------------------------------------------------
double CTimer::TimeElapsed()
{
//得到本次定时已经用了多少秒
QueryPerformanceCounter( (LARGE_INTEGER*)&m_CurrentTime);
m_TimeElapsed = (m_CurrentTime -m_LastTime) * m_TimeScale;
m_LastTime =m_CurrentTime;
return m_TimeElapsed;
}
========================================================================================
/////////////////////////////////////
///////////////////////////////////////
///////////////////////////////////////
#ifndef CTIMER_H
#define CTIMER_H
//-----------------------------------------------------------------------
//
// Name: CTimer.h
//
// Author: Mat Buckland 2002
//
// Desc: Windows timer class for the book GameAI
// Programming with Neural Nets and GeneticAlgorithms.
//
//-----------------------------------------------------------------------
#include
class CTimer
{
private:
LONGLONG m_CurrentTime,
m_LastTime,
m_NextTime,
m_FrameTime,
m_PerfCountFreq;
double m_TimeElapsed,
m_TimeScale;
float m_FPS;
public:
//ctors
CTimer();
CTimer(float fps);
//whatdayaknow, this starts the timer
void Start();
//determines if enough time has passed to moveonto next frame
bool ReadyForNextFrame();
//only use this after a call to theabove.
double GetTimeElapsed(){returnm_TimeElapsed;}
double TimeElapsed();
};
#endif
三.使用举例
int WINAPI WinMain (HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR szCmdLine,
int iCmdShow)
{
//handle to our window
HWND hWnd;
//our window classstructure
WNDCLASSEX winclass;
// first fill in the window class stucture
winclass.cbSize = sizeof(WNDCLASSEX);
winclass.style = CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc =WindowProc;
winclass.cbClsExtra = 0;
winclass.cbWndExtra = 0;
winclass.hInstance = hInstance;
winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
winclass.hCursor = LoadCursor(NULL, IDC_ARROW);
winclass.hbrBackground = NULL;
winclass.lpszMenuName = NULL;
winclass.lpszClassName = g_szWindowClassName;
winclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
//register the windowclass
if(!RegisterClassEx(&winclass))
{
MessageBox(NULL,"Registration Failed!", "Error", 0);
//exit theapplication
return0;
}
//create the window andassign its ID tohwnd
hWnd = CreateWindowEx(NULL, // extended style
g_szWindowClassName, // window class name
g_szApplicationName, // window caption
WS_OVERLAPPEDWINDOW, // window style
0, // initial x position
0, // initial y position
WINDOW_WIDTH, // initial x size
WINDOW_HEIGHT, // initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL); // creation parameters
//make sure the window creation has gone OK
if(!hWnd)
{
MessageBox(NULL, "CreateWindowEx Failed!", "Error!", 0);
}
//make the window visible
ShowWindow (hWnd,iCmdShow);
UpdateWindow (hWnd);
// Enterthe message loop
bool bDone =false;
//create a timer
CTimertimer(FRAMES_PER_SECOND);
//start the timer
timer.Start();
MSG msg;
while(!bDone)
{
while(PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
if( msg.message == WM_QUIT )
{
// Stop loop if it's a quit message
bDone = true;
}
else
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
if(timer.ReadyForNextFrame())
{
//**any gameupdate code goes in here**
//this will call WM_PAINT which will render our scene
InvalidateRect(hWnd,NULL, TRUE);
UpdateWindow(hWnd);
}
}//endwhile
UnregisterClass( g_szWindowClassName, winclass.hInstance );
return msg.wParam;
}
发表评论
-
win下开发跨平台GUI程序的另类选择
2011-05-03 17:21 2145GTK+ ● GTK+的网站:www.gtk. ... -
win32汇编-送消息给其它应用程序
2010-02-20 16:42 28682个函数invoke postmessage,hwnd,msg ... -
WIN32汇编之菜单、加速键、快捷键
2010-02-20 16:38 3077(一)Invoke checkmenuitem,h ... -
WIN32汇编学习应用之defwindowproc
2010-02-20 16:36 2664defwindowproc窗口过程对一些消息的默认处理方式WM ... -
windows中WM_CLOSE消息和WM_DESTORY消息的不同之处
2010-02-20 16:33 23871、WM_CLOSE仅代表用户发出了关闭的指令,但窗口过程可以 ... -
WIN32汇编获取应用程序句柄
2010-02-20 16:32 2119getmodulehandle使用方法invoke getm ... -
WIN32汇编语言学习应用之消息获取
2010-02-20 16:31 1679MSG结构:MSG STURCTHwnd DWORD ?Mes ... -
一个WIN32汇编的完整窗口入门程序的理解与注释
2010-02-20 16:28 3656;WIN32汇编的注释是;,其实WIN32汇编和VC有很多 ... -
汇编中通用寄存器的目的
2010-02-20 16:24 21001、EAX和AX:累加器,所有的I/O指令用它来与外部设备 ... -
汇编几个段
2010-02-17 16:39 4179反汇编后几个段的含义 预定义段 一个WindowsNT ... -
WIN32汇编语言解析
2010-02-17 16:36 2517win32汇编中的sizeof win32汇编中的s ... -
设置与获取窗口标题文本
2010-02-17 16:32 1959获得: CString xx=""; ... -
win32汇编快速入门
2010-02-17 16:31 4618汇编可以开发WINDOWS程序 ... -
WIN32汇编-HELLO,WORLD!
2010-02-17 16:29 4338我们用WIN32汇编构建 ... -
保护模式下段寄存器的作用
2010-02-17 14:39 31521、保护模式一,虽然在寻址上没有分段的限制问题,但对要对一个地 ... -
WIN32汇编-反汇编
2010-02-17 14:33 2745学好WIN32汇编,平时需 ... -
玩转菜单-菜单资源
2010-02-08 17:31 1892菜单资源 WINDOWS程序的菜单通常编译前定义在资 ... -
二进制资源和自定义资源使用定义
2010-02-08 17:29 21451、二进制资源 (1)定义格式: 资源IDRCDA ... -
LISTBOX和LIST CONTROL的项目增加方法
2010-02-08 17:28 53991、LIST CONTROL(report方式): (1)类 ... -
取IP寄存器的当前值
2010-02-08 17:27 1864call $+3 POP CX 把IP寄存器的当前值放 ...
相关推荐
Windows计时器精确到微妙
基于Windows 的高精度实时定时程序,精度可达到微秒级,可以用来发送串口数据等
这种算法在一定程度上解决了其他基于训练序列的同步算法(如S&C算法)存在的“平台效应”问题,从而实现了更精确的符号定时。 5.注意事项:注意MATLAB左侧当前文件夹路径,必须是程序所在文件夹位置,具体可以参考...
可实现精确定时,是并行于windows的程序系统。
定时清理Windows的指定的目录程序 定时关机程序 lzsslib 得到一个进程的状态 如是否没有反应 得到经过关联的文件类型图标 MAKEMDI2 得到当前进程的运行命令行信息 MB VIEW 存取注册表的类 NT 性能统计类 磁盘引导区...
6、附带一个精确至百分之一秒的秒表(计时器),从中可查看Windows 和定时器运行了多长时间。 7、附带系统锁定功能,用户离开计算机时可以暂时锁定计算机。 8、软件连安装程序小于100KB,方便网友下载使用。 ★...
定时任务提供了定时关机、重启、注销、锁定、待机、休眠、提醒、打开或关闭程序、删除文件/文件夹、备份文件/文件夹、断开网络拔号连接等操作任务。 贴心的定时多任务管理 可随意按每年、每月、每周、...
20.15 执行客户端的可执行程序 20.16 自动调用OutLook发送邮件 20.17 弹出窗口选择颜色 20.18 弹出框式邮件发送 20.19 把网站作为用户的Active桌面 20.20 判断是否安装了flash插件 第21章 流行技术:DOM和userData的...
Perfect Backup 是适用于 Windows 的全功能定时备份软件,支持自定义文件、文件夹、应用数据以及驱动器映像备份到本地或外部驱动器、网络位置、FTP 服务器和云盘,支持电子邮件通知,软件操作简单。 可备份到任何...
20.15 执行客户端的可执行程序 20.16 自动调用OutLook发送邮件 20.17 弹出窗口选择颜色 20.18 弹出框式邮件发送 20.19 把网站作为用户的Active桌面 20.20 判断是否安装了flash插件 第21章 流行技术:DOM和userData的...
定时/计数器的工作可以由编程来实现定时、计数和产生计数溢出中断要求的功 能。在构成为定时器时,每个机器周期加1 (使用12MHz 时钟时,每1us 加1),这 样以机器周期为基准可以用来测量时间间隔。在构成为计数器时,在...
registry.zip 读和写注册表文件的例子(7KB) 678,xcopy.zip 模仿dos命令xcopy的功能(3KB) 679,winpaths.zip 得到计算机上windows目录和系统目录(3KB) 680,tray.zip 实现托盘程序(9KB) 681,...
registry.zip 读和写注册表文件的例子(7KB) 678,xcopy.zip 模仿dos命令xcopy的功能(3KB) 679,winpaths.zip 得到计算机上windows目录和系统目录(3KB) 680,tray.zip 实现托盘程序(9KB) 681,...
registry.zip 读和写注册表文件的例子(7KB) 678,xcopy.zip 模仿dos命令xcopy的功能(3KB) 679,winpaths.zip 得到计算机上windows目录和系统目录(3KB) 680,tray.zip 实现托盘程序(9KB) 681,...
registry.zip 读和写注册表文件的例子(7KB) 678,xcopy.zip 模仿dos命令xcopy的功能(3KB) 679,winpaths.zip 得到计算机上windows目录和系统目录(3KB) 680,tray.zip 实现托盘程序(9KB) 681,...
9.支持五种硬盘数据还原方式:不还原、自动还原、手动还原、定时还原和数据转储。 10.移除方式灵活。在 Windows 下移除还原精灵,会询问是否需要还原或转储数据。 11.提供还原 CMOS 功能。当 CMOS 更改后,可以选择...
windows有很多内核对象,其中可等待定时器对象是一种由系统维护的,精确的定时激发的内核对象,熟练应用可等待定时器对象可以让你在自己的时间控制程序中更好地对时间事件进行控制,避免由于自己对时间控制的维护...
<br>提供命令行调用方式,方便集成到每日构建框架,或每日配置管理简报,或者简单地利用Windows任务计划定时执行。 <br>提供C#源代码,方便大家进行修改和补充完善。程序利用VSS提供的自动化编程接口IVSS对...
每个人都有一些自己的秘密不想让别人知道,独特的——“私人磁盘”工具,在您的电脑上为您开辟一块私人空间,windows下访问不到,删除不了,百毒不侵,您设置的密码是您进入您的磁盘的唯一依据。即使重装机也丢失不...
6.20 精确和安全地使用协作的超类调用 270 第7章 持久化和数据库 273 引言 273 7.1 使用marshal模块序列化数据 275 7.2 使用pickle和cPickle模块序列化数据 277 7.3 在Pickling的时候压缩 280 7.4 对类和实例...