If you need a timer for the entire duration of your program, you'll probably call SetTimer from the WinMain function or while processing the WM_CREATE message, and KillTimer in response to a WM_DESTROY message. Setting the timer in WinMain provides the easiest error handling if a timer is unavailable. You can use a timer in one of three ways, depending on the parameters to the SetTimer call.