win32下timer示例

// win32-timer.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <Windows.h>

void CALLBACK TimerProc(HWND hwnd, UINT message, UINT timerID, DWORD time)
{
 MessageBeep(-1);
 printf("%s\n","a");
}

int _tmain(int argc, _TCHAR* argv[])
{
 MSG msg;

 SetTimer(NULL, 0, 3000, TimerProc);
 while (GetMessage(&msg, NULL, 0, 0))
 {
  TranslateMessage(&msg);
  DispatchMessage(&msg);
 }
 KillTimer(NULL, 1);

 return 0;
}

原文地址:https://www.cnblogs.com/chuncn/p/1406939.html