日期:2014-05-18 浏览次数:20798 次
/// <summary> /// 多媒体事件的委托 /// </summary> private delegate void TimeProc(uint id, uint msg, int user, int dw1, int dw2); /// <summary> /// 多媒体精度测试,详细信息,请参见多媒体sdk /// </summary> [DllImport("Winmm.dll")] private extern static int timeGetDevCaps(out TIMECAPS ptc, int cbtc); /// <summary> /// 设置最小精度,详细信息,请参见多媒体sdk /// </summary> [DllImport("Winmm.dll")] private extern static int timeBeginPeriod(uint timerRes); /// <summary> /// 开始指定定时器事件,这个定时器运行在自己的线程中,激活之后,它将在指定的时间调用回调函数或 /// 有节奏的设置事件对象,详细信息,请参见多媒体sdk /// </summary> [DllImport("Winmm.dll")] private extern static int timeSetEvent(uint delay, uint resolution, TimeProc timeProc, int user, uint fuEvent); /// <summary> /// 清除设置最小精度,详细信息,请参见多媒体sdk /// </summary> [DllImport("Winmm.dll")] private extern static int timeEndPeriod(uint timerRes); /// <summary> /// 取消指定定时器事件,详细信息,请参见多媒体sdk /// </summary> [DllImport("Winmm.dll")] private extern static int timeKillEvent(int timeId);
------解决方案--------------------
Multimedia SDK里有一组Timer服务.按MSDN的原话说:
Multimedia timer services allow applications to schedule timer events with the greatest resolution (or accuracy) possible for the hardware platform. These multimedia timer services allow you to schedule timer events at a higher resolution than other timer services.
其中包含以下几个函数:
timeBeginPeriod
timeEndPeriod
timeGetDevCaps
timeGetSystemTime
timeGetTime
timeKillEvent
TimeProc
timeSetEvent
具体没仔细研究过不知道怎么用.
LZ可以去啃啃MSDN,上面有例子.