CreateWatchDogTimer (Compact 2013)


This function creates a watchdog timer.

HANDLE CreateWatchDogTimer(
  LPCWSTR pszWatchDogName,
  DWORD dwPeriod,
  DWORD dwWait,
  DWORD dwDfltAction,
  DWORD dwParam,
  DWORD dwFlags


[in] Name of the watchdog timer to be created.


[in] Watchdog period, in milliseconds.


[in] Time to wait, in milliseconds, when the watchdog timer is not refreshed within the watchdog period before the default action is taken.

This is useful when handling false alarms or saving important information before system reset.


[in] Default action to be taken when the watchdog timer is not refreshed within dwPeriod.

The following table describes possible values.




Terminate the process to be watched.


Take no default action.


Reset the device.


[in] Parameter to be passed to IOCTL_HAL_REBOOT.

The OEM adaptation layer (OAL) uses this information to determine whether an immediate system reboot is needed, or to perform a delayed system reboot.


[in] Reserved; must be set to zero.

A handle to the watchdog timer indicates success. NULL indicates failure.

The returned handle can be used in WaitForSingleObject or WaitForMultipleObjects, and is signaled when the watchdog is not refreshed within the specified watchdog period, dwPeriod. Use the CloseHandle function to release the memory used by the watchdog timer.

If a watchdog timer with the name specified by pszWatchDogName exists, a new handle is returned, and GetLastError returns ERROR_ALREADY_EXISTS. Although the handle returned does not have the same value as the first one, it still references the same underlying object.

Watchdog timers are used to make sure critical processes are running as expected. Typically, every critical process creates a watchdog timer and refreshes it by calling the RefreshWatchDogTimer function from time to time to make sure that the watchdog is working correctly.

You can create a monitor process to wait on the watchdog handles to perform actions if the critical processes fail to signal the watchdog timers.

If the critical process fails to refresh its watchdog timer within the watchdog period specified by dwPeriod, the watchdog is signaled.

The monitor process, if it exists, has up to dwWait milliseconds to determine whether it is a false alarm, or save critical information before the default action is taken.

In case of a false alarm, the monitor process should refresh the watchdog to prevent the default action from being taken.

When the default action is taken, the watchdog is considered stopped. That is, the same watchdog timer is not signaled again until it is started again.