[适用于 KMDF 和 UMDF]
WdfIoTargetClose 方法关闭指定的远程 I/O 目标。
语法
void WdfIoTargetClose(
[in] WDFIOTARGET IoTarget
);
参数
[in] IoTarget
从上一次调用 WdfIoTargetCreate获取的 I/O 目标对象的句柄。
返回值
没有
注解
如果驱动程序提供无效的对象句柄,则会发生 bug 检查。
在驱动程序调用 WdfIoTargetClose后,它可以调用 WdfIoTargetOpen 以重新打开远程 I/O 目标。
提供 EvtIoTargetRemoveComplete 回调函数的驱动程序必须从该回调函数中调用 WdfIoTargetClose。
在 WdfIoTargetClose 方法返回之前,框架 取消 所有目标队列的 I/O 请求。
如果驱动程序已使用远程 I/O 目标完成,并且不会再次使用该目标,并且目标没有仍在挂起的子请求对象,则驱动程序可以在不首先调用 WdfIoTargetClose的情况下调用 WdfObjectDelete。 调用 WdfObjectDelete 将关闭远程 I/O 目标,取消所有目标队列的 I/O 请求,并删除 I/O 目标对象。 (请注意,如果远程 I/O 目标的父对象是设备对象,框架将关闭目标,并在删除父对象时删除目标对象。如果目标有任何仍在挂起的子请求对象,驱动程序必须先调用 WdfIoTargetClose,然后才能安全地调用 WdfObjectDelete。
有关 WdfIoTargetClose的详细信息,请参阅 控制常规 I/O 目标的状态。
有关 I/O 目标的详细信息,请参阅 使用 I/O 目标。
例子
下面的代码示例是一个 EvtIoTargetRemoveComplete 回调函数,该函数从驱动程序的 I/O 目标集合中删除指定的 I/O 目标,然后关闭 I/O 目标。
VOID
MyEvtIoTargetRemoveComplete(
WDFIOTARGET IoTarget
)
{
//
// Get device information from the I/O target object's
// context space.
//
targetDeviceInfo = GetTargetDeviceInfo(IoTarget);
deviceExtension = targetDeviceInfo->DeviceExtension;
//
// Remove the target device from the collection.
//
WdfWaitLockAcquire(
deviceExtension->TargetDeviceCollectionLock,
NULL
);
WdfCollectionRemove(
deviceExtension->TargetDeviceCollection,
IoTarget
);
WdfWaitLockRelease(deviceExtension->TargetDeviceCollectionLock);
//
// Close the target.
//
WdfIoTargetClose(IoTarget);
}
要求
要求 | 价值 |
---|---|
目标平台 | 普遍 |
最低 KMDF 版本 | 1.0 |
最低 UMDF 版本 | 2.0 |
标头 | wdfiotarget.h (包括 Wdf.h) |
图书馆 | Wdf01000.sys(KMDF):WUDFx02000.dll (UMDF) |
IRQL | PASSIVE_LEVEL |
DDI 符合性规则 | DriverCreate(kmdf),KmdfIrql(kmdf),KmdfIrql2(kmdf),KmdfIrqlExplicit(kmdf) |