Code:
// timer with callback
#define WIN32_DEFAULT_LIBS
#include<windows.h>
#include <stdio.h>
void CALLBACK TimeProc(HWND wnd, UINT msg, UINT event, DWORD time)
{
printf("Hello world... on a timer!\n");
Beep(500,100);
}
int main (void)
{ MSG msg;
if (! SetTimer(NULL,0,1000,TimeProc) )
printf("Well that didn't work");
while( GetMessage(&msg,NULL,0,0) )
DispatchMessage(&msg);
return 0;
}
Please note ... the message dispatcher loop has to run in order for the timer to execute.
This means your code will have to also contain a windows MsgProc() or *at least* idle in this loop.
I would also suggest you experiment with Salem's method from message #2... use the one that works best for you.