SwDeviceInterfaceSetState function (swdevice.h)

Enables or disables a device interface for a software device.


HRESULT SwDeviceInterfaceSetState(
  [in] HSWDEVICE hSwDevice,
  [in] PCWSTR    pszDeviceInterfaceId,
  [in] BOOL      fEnabled


[in] hSwDevice

The HSWDEVICE handle to the software device to register a device interface for.

[in] pszDeviceInterfaceId

A string that identifies the interface to enable or disable.

[in] fEnabled

A Boolean value that indicates whether to either enable or disable the interface. TRUE to enable; FALSE to disable.

Return value

S_OK is returned if SwDeviceInterfaceSetState successfully enabled or disabled the interface; otherwise, an appropriate error value.


You can call SwDeviceInterfaceSetState only after the operating system has called your client app's SW_DEVICE_CREATE_CALLBACK callback function to notify the client app that device enumeration completed.

You can only use SwDeviceInterfaceSetState to manage interfaces that were previously registered with SwDeviceInterfaceRegister against the software device that hSwDevice represents.

Client apps use SwDeviceInterfaceSetState to manage the state that they want the interface to have. The software device changes the actual interface state as needed. For example, a client app disables and re-enables the interface if the device is re-enumerated for any reason. The state always tries to reflect the client app’s required state.


Requirement Value
Minimum supported client Windows 8
Minimum supported server Windows Server 2012
Target Platform Universal
Header swdevice.h
Library Swdevice.lib; OneCoreUAP.lib on Windows 10
DLL Cfgmgr32.dll