SetupDiRemoveDeviceInterface function (setupapi.h)

The SetupDiRemoveDeviceInterface function removes a registered device interface from the system.

Syntax

WINSETUPAPI BOOL SetupDiRemoveDeviceInterface(
  [in]      HDEVINFO                  DeviceInfoSet,
  [in, out] PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData
);

Parameters

[in] DeviceInfoSet

A pointer to the device information set that contains the device interface to remove. This handle is typically returned by SetupDiGetClassDevs.

[in, out] DeviceInterfaceData

A pointer to an SP_DEVICE_INTERFACE_DATA structure that specifies the device interface in DeviceInfoSet to remove. This pointer is typically returned by SetupDiEnumDeviceInterfaces.

After the interface is removed, this function sets the SPINT_REMOVED flag in DeviceInterfaceData.Flags. It also clears the SPINT_ACTIVE flag, but be aware that this flag should have already been cleared before this function was called.

Return value

SetupDiRemoveDeviceInterface returns TRUE if the function completed without error. If the function completed with an error, it returns FALSE and the error code for the failure can be retrieved by calling GetLastError.

Remarks

The caller of this function must be a member of the Administrators group.

SetupDiRemoveDeviceInterface removes the specified device interface from the system. This includes deleting the associated registry key.

Call SetupDiDeleteDeviceInterfaceData to delete the interface from a device information list.

A device interface must be disabled to be removed. If the interface is enabled, this function fails and GetLastError returns ERROR_DEVICE_INTERFACE_ACTIVE. Disable an interface by using whatever interface-specific mechanism is provided (for example, an IOCTL). If the caller has no way to disable an interface and the interface must be removed, the caller must stop the underlying device by using SetupDiChangeState. Stopping the device disables all the interfaces exposed by the device.

Requirements

Requirement Value
Minimum supported client Available in Microsoft Windows 2000 and later versions of Windows.
Target Platform Desktop
Header setupapi.h (include Setupapi.h)
Library Setupapi.lib
DLL Setupapi.dll

See also

SetupDiChangeState

SetupDiCreateDeviceInterface

SetupDiDeleteDeviceInterfaceData

SetupDiEnumDeviceInterfaces

SetupDiGetClassDevs