Posted By


igamojp on 08/01/06

Tagged


Statistics


Viewed 1365 times
Favorited by 1 user(s)

Multimedia Timer


/ Published in: C++
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /**
  2.  * Multimedia Timer
  3.  *
  4.  * Timer Interrupttion per interval[ms]
  5.  */
  6.  
  7. #include<windows.h>
  8. #include<mmsystem.h>
  9.  
  10. #pragma comment(lib, "winmm.lib")
  11.  
  12. void CALLBACK TimeProc(UINT uTimerID, UINT uMsg,
  13. DWORD dwUser, DWORD dw1, DWORD dw2)
  14. {
  15. /**
  16.   * Timer Interruption
  17.   */
  18. }
  19.  
  20. void main()
  21. {
  22. UINT uDelay = 1000;
  23. UINT uResolution = 1;
  24. DWORD dwUser = NULL;
  25. UINT fuEvent = TIME_PERIODIC; //You also choose TIME_ONESHOT;
  26.  
  27. MMRESULT FTimerID;
  28. timeBeginPeriod(1);
  29. FTimerID = timeSetEvent(uDelay, uResolution, TimeProc, dwUser, fuEvent);
  30. if(FTimerID==NULL){
  31. printf("Failed to generate multimedia timer.\n");
  32. }
  33.  
  34. Sleep(10000);
  35.  
  36. timeKillEvent(FTimerID);
  37. timeEndPeriod(1);
  38. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.