- 注册时间
- 2011-3-6
- 最后登录
- 1970-1-1
该用户从未签到
|
使用timeSetEvent
- #include <stdio.h>
- #include <Windows.h>
- #include <Mmsystem.h>
- #pragma comment(lib, "Winmm.lib")
- void WINAPI OnTimeFunc(UINT wTimerID, UINT msg,DWORD dwUser,DWORD dwl,DWORD dw2)
- {
- printf("OnTimeFunc\n");
- }
- int main(int argc, char * argv[])
- {
- MMRESULT timer_id;
- timer_id = timeSetEvent(1000, 1, (LPTIMECALLBACK)OnTimeFunc, DWORD(1), TIME_PERIODIC);
- if(NULL == timer_id)
- {
- printf("timeSetEvent error!--code:0x%x\n",GetLastError());
- return 0;
- }
- printf("input any key KillTimer!\n");
- getchar();
- timeKillEvent(timer_id); //释放定时器
- printf("input any key Exit!\n");
- return 1;
- }
复制代码 |
|