The third method of setting the timer is similar to the second method. It requires a far pointer created from MakeProcInstance to a function that processes the WM_TIMER messages. However, the hwnd parameter to SetTimer is set to NULL, and the second parameter (normally the timer ID) is ignored. Instead, the function returns a timer ID:
nTimerID = SetTimer (NULL, 0, wMsecInterval, lpfnTimerProc) ;
The nTimerID returned from SetTimer will be NULL if no timer is available.
The first parameter to KillTimer (usually the window handle) must also be NULL. The timer ID must be the value returned from SetTimer:
KillTimer (NULL, nTimerID) ;
The hwnd parameter passed to the TimerProc timer function will also be NULL. The wParam parameter is the timer ID, and lParam is lpfnTimerProc, the same as in the second method.
This method for setting a timer is rarely used. It might come in handy if you do a lot of SetTimer calls at different times in your program and don't want to keep track of which timer IDs you've already used.
Now that you know how to use the Windows timer, you're ready for a couple of useful timer programs.