Microsoft KB Archive/312406
Article ID: 312406
Article Last Modified on 2/12/2007
- Microsoft Windows 95
- Microsoft Windows 98 Standard Edition
- Microsoft Windows 98 Second Edition
This article was previously published under Q312406
When two applications create timers by calling the SetTimer function, and the window handle is set to NULL, one application may kill the timer created by the other application.
This behavior can occur under the following scenario:
- Application A allocates a timer (id=A), and then kills it.
- Application B allocates a timer (id=A is reused).
- Application A kills this timer again.
- Application A allocates a timer (id=A is reused), and then kills it.
- Application B attempts to kill the timer (id=A), but this operation fails.
This behavior can occur because timers are allocated from a global resource. When the KillTimer function is called with a timer ID, it destroys any timer that it is directed to. Furthermore, SetTimer may reuse timer IDs when the window handle parameter is set to NULL. In this case -- where multiple applications create and destroy timers against the NULL window, and one application destroys a timer twice -- the possibility of a collision exists.
To resolve this issue, modify your code so that it always uses a non-NULL window handle when it creates timers.
This behavior is by design.
Keywords: kbprb KB312406