程序每隔1秒定时输出
i get a word:
Hello
源代码如下:
#include <windows.h>
#include <stdio.h>
VOID CALLBACK TimerProc(HWND,UINT,UINT,DWORD)//回调函数
{
printf("Hello\n");
}
int main()
{
SetTimer(NULL,1,1000,TimerProc);//定时器
MSG msg;
while(GetMessage(&msg, NULL,NULL,NULL))//读取消息
{
if(msg.message == WM_TIMER)
{
printf("i get a word:\n");
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return 0;
}