IoDetachDevice function (wdm.h)

The IoDetachDevice routine releases an attachment between the caller's device object and a lower driver's device object.

Syntax

void IoDetachDevice(
  [in, out] PDEVICE_OBJECT TargetDevice
);

Parameters

[in, out] TargetDevice

Pointer to the lower driver's device object. The caller previously called IoAttachDevice or IoAttachDeviceToDeviceStack successfully to get this pointer.

Return value

None

Remarks

IoDetachDevice decrements the reference count of the TargetDevice object. If the reference count goes to zero and the lower driver has been marked for an unload operation, the lower driver is unloaded.

Requirements

Requirement Value
Minimum supported client Available starting with Windows 2000.
Target Platform Universal
Header wdm.h (include Wdm.h, Ntddk.h, Ntifs.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe
IRQL PASSIVE_LEVEL
DDI compliance rules HwStorPortProhibitedDDIs(storport), IrqlIoPassive3(wdm), PnpSurpriseRemove(wdm), PowerIrpDDis(wdm), RemoveLockCheck(wdm)

See also

IoAttachDevice

IoAttachDeviceToDeviceStack