VC++ 高精度定时timeSetEvent和回调成员方法

本文介绍了如何在VC++中使用timeSetEvent创建精度达到1ms的高精度定时器,并解决成员方法不能直接作为回调函数的问题。建议使用静态方法配合传递this指针来调用成员方法,同时提到了这种方法可能的效率问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

Platform SDK: Windows Multimedia中的timeSetEvent函数和timeKillEvent函数可以启动和停止一个精度达到1ms的高精度定时器。

原型:

MMRESULT timeSetEvent(

  UINT           uDelay,     

  UINT           uResolution,

  LPTIMECALLBACK lpTimeProc, 

  DWORD_PTR      dwUser,     

  UINT           fuEvent     

);

Parameters

uDelay

Event delay, in milliseconds. If this value is not in the range of the minimum and maximum event delays supported by the timer, the function returns an error.

事件延迟,毫秒。如果这个值不在定时器支持的最小和最大延时之间的话,函数将返回一个错误。

uResolution

Resolution of the timer event, in milliseconds. The resolution increases with smaller values; a resolution of 0 indicates periodic events should occur with the greatest possible accuracy. To reduce system overhead, however, you should use the maximum value appropriate for your application.

定时器的分辨力,毫秒。小的数值表示高的分辨力;分辨力为0表示周期事件应该以允许的最高精度发生。尽管如此为减小系统开销,你应该使用适合你应用的最大值。

lpTimeProc

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值