WdfTimerCreate function (wdftimer.h)
[Applies to KMDF and UMDF]
The WdfTimerCreate method creates a framework timer object.
Syntax
NTSTATUS WdfTimerCreate(
[in] PWDF_TIMER_CONFIG Config,
[in] PWDF_OBJECT_ATTRIBUTES Attributes,
[out] WDFTIMER *Timer
);
Parameters
[in] Config
A pointer to a WDF_TIMER_CONFIG structure.
[in] Attributes
A pointer to a WDF_OBJECT_ATTRIBUTES structure that contains object attributes for the new timer object.
[out] Timer
A pointer to a location that receives a handle to the new framework timer object.
Return value
WdfTimerCreate returns STATUS_SUCCESS if the operation succeeds. Otherwise, this method might return one of the following values:
Return code | Description |
---|---|
|
The Attributes parameter was NULL, or the ParentObject member of the WDF_OBJECT_ATTRIBUTES structure that Attributes specifies was NULL. |
|
An invalid parameter was specified. |
|
The ParentObject member of the WDF_OBJECT_ATTRIBUTES structure did not reference a framework device object or an object whose chain of parents leads to a framework device object. |
|
There was insufficient memory. |
|
The AutomaticSerialization member of the WDF_TIMER_CONFIG structure was set to TRUE, but the parent device object's execution level was set to WdfExecutionLevelPassive. |
For a list of other return values that the WdfTimerCreate method might return, see Framework Object Creation Errors.
This method might also return other NTSTATUS values.
Remarks
When your driver calls WdfTimerCreate, it must supply a WDF_OBJECT_ATTRIBUTES structure and must specify a parent object in the structure's ParentObject member. The parent object can be a framework device object or any object whose chain of parents leads to a framework device object. The framework will delete the timer object when it deletes the device object.
After creating a timer object, the driver must call WdfTimerStart to start the timer's clock regardless of whether the timer is periodic or not.
If your driver provides EvtCleanupCallback or EvtDestroyCallback callback functions for the framework timer object, note that the framework calls these callback functions at IRQL = PASSIVE_LEVEL.
For more information about framework timer objects, see Using Timers.
Examples
The following code example initializes a WDF_TIMER_CONFIG structure and a WDF_OBJECT_ATTRIBUTES structure and then calls WdfTimerCreate.
WDF_TIMER_CONFIG timerConfig;
WDF_OBJECT_ATTRIBUTES timerAttributes;
WDFTIMER timerHandle;
NTSTATUS status;
WDF_TIMER_CONFIG_INIT(
&timerConfig,
MyEvtTimerFunc
);
timerConfig.AutomaticSerialization = TRUE;
WDF_OBJECT_ATTRIBUTES_INIT(&timerAttributes);
timerAttributes.ParentObject = DeviceHandle;
status = WdfTimerCreate(
&timerConfig,
&timerAttributes,
&timerHandle
);
if (!NT_SUCCESS(status)) {
return status;
}
Requirements
Requirement | Value |
---|---|
Target Platform | Universal |
Minimum KMDF version | 1.0 |
Minimum UMDF version | 2.0 |
Header | wdftimer.h (include Wdf.h) |
Library | Wdf01000.sys (KMDF); WUDFx02000.dll (UMDF) |
IRQL | <=DISPATCH_LEVEL |
DDI compliance rules | DriverCreate(kmdf), KmdfIrql(kmdf), KmdfIrql2(kmdf), KmdfIrqlExplicit(kmdf) |