SetupDiUnremoveDevice function

The SetupDiUnremoveDevice function is the default handler for the DIF_UNREMOVE installation request.


WINSETUPAPI BOOL SetupDiUnremoveDevice(
  HDEVINFO         DeviceInfoSet,



A handle to a device information set for the local system that contains a device information element that represents a device to restore and to restart.


A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet. This is an IN-OUT parameter because DeviceInfoData.DevInst might be updated with a new handle value on return.

Return Value

The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved by a call to GetLastError.


SetupDiUnremoveDevice restores a device to a hardware profile. This function starts the device, if possible, or it sets a flag in the device install parameters that eventually causes the user to be prompted to shut down the system.

Note  Only a class installer should call SetupDiUnremoveDevice and only in those situations where the class installer must perform device unremove operations after SetupDiUnremoveDevice completes the default device unremove operation. In such situations, the class installer must directly call SetupDiUnremoveDevice when the installer processes a DIF_UNREMOVE request. For more information about calling the default handler, see Calling Default DIF Code Handlers.
The device being restored must have class install parameters for DIF_UNREMOVE or the function fails and GetLastError returns ERROR_NO_CLASSINSTALL_PARAMS.

The DeviceInfoSet must only contain elements on the local computer.

The caller of SetupDiUnremoveDevice must be a member of the Administrators group.


Windows version 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