Posted By

igamojp on 08/01/06


Tagged

time


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

copyleft


Multimedia Timer


 / Published in: C++
 

  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  

You need to login to post a comment.