DriverPackageUninstall function

Starting in Windows 10 Version 1607 (Redstone 1), the Driver Install Frameworks (DIFx) tools are no longer included in the WDK.

For more information, see DIFx Guidelines.

The DriverPackageUninstall function uninstalls the specified driver package from the system and removes the driver package.

Syntax

DWORD DriverPackageUninstall(
  _In_PCTSTR DriverPackageInfPath,
  _In_DWORD Flags,
  _In_opt_PCINSTALLERINFO_W pInstallerInfo,
  _Out_BOOL *pNeedReboot
);

Parameters

DriverPackageInfPath [in]

A pointer to a NULL-terminated string that supplies the fully qualified path of the driver package'sINF file of the driver package to uninstall.

Flags [in]

A bitwise OR of the flags in the following table that control the uninstall operation.

Value Meaning
0x00000000 DriverPackageUninstall performs a default uninstall operation.
DRIVER_PACKAGE_DELETE_FILES DriverPackageUninstall removes the binary files that were copied to the system when the [driver package](https://msdn.microsoft.com/library/windows/hardware/ff544840) was installed. A caller should use this flag with caution. A caller should only use this flag if the caller can verify that a binary file in the system is not required by any other driver package or application.

Starting with Windows 7, the DRIVER_PACKAGE_DELETE_FILES flag is ignored by DriverPackageUninstall. Binary files, which were copied to a system when a driver package was installed, can no longer be deleted by calling this function.

DRIVER_PACKAGE_FORCE DriverPackageUninstall uninstalls the driver package even if the driver package is currently associated with an installed application or is installed on devices in the device tree. A caller should use this flag with caution. For more information, see the following Remarks section.
DRIVER_PACKAGE_SILENT DriverPackageUninstall uninstalls the driver package without displaying any user dialog boxes or other user messages. If a user dialog box is required to complete the uninstall operation, the driver package is not uninstalled. If an error occurs during the uninstall operation, the function returns a status code that indicates the type of error.

pInstallerInfo [in, optional]

A pointer to a constant INSTALLERINFO structure that supplies information about an application, if any, that was associated with a driver package when the driver package was installed by a call to DriverPackageInstall. This pointer is optional and can be NULL.

pNeedReboot [out]

A pointer to a BOOL-typed variable. On return, this variable indicates, if TRUE, that a system restart is required to complete the uninstall operation. If the value, on return, is FALSE, a system restart is not required.

Return value

DriverPackageUninstall returns ERROR_SUCCESS if the driver package was successfully uninstalled. Otherwise, the function did not uninstall the driver package and returns an error code that indicates the cause of the failure. The following tables contains the most common return values.

Return code Description
CRYPT_E_FILE_ERROR The catalog file for the specified driver package was not found; or possibly, some other error occurred when DriverPackageUninstall tried to verify the driver package signature.
ERROR_ACCESS_DENIED A caller of DriverPackageUninstall must be a member of the Administrators group to uninstall a driver package.
ERROR_BAD_ENVIRONMENT The current Microsoft Windows version does not support this operation. An old or incompatible version of DIFxApp.dll or DIFxAppA.dll might be present in the system.
ERROR_CANT_ACCESS_FILE The driver package files could not be accessed. One possibility is that the specified INF file is in the system INF directory and the driver package is not preinstalled.
ERROR_DEPENDENT_APPLICATIONS_EXIST DriverPackageUninstall removed an association between the driver package and the specified application but the function did not uninstall the driver package because other applications are associated with the driver package. For more information, see the following Remarks section.
ERROR_DRIVER_PACKAGE_NOT_IN_STORE There is no INF file that corresponds to the INF file that was specified by DriverPackageInfPath.
ERROR_FILE_NOT_FOUND The INF file that was specified by DriverPackageInfPath was not found.
ERROR_FILENAME_EXCED_RANGE The length, in characters, of the specified INF file path is greater than the maximum supported length.
ERROR_IN_WOW64 The 32-bit version DIFxAPI does not work on Win64 systems. A 64-bit version of DIFxAPI is required.
ERROR_INSTALL_FAILURE The uninstall operation failed.
ERROR_INVALID_NAME The specified INF file path is not valid.
ERROR_INVALID_PARAMETER A supplied parameter is not valid.
ERROR_OUTOFMEMORY Available system memory was insufficient to perform the operation.
ERROR_SHARING_VIOLATION A component of the driver package is locked by a thread or process. This error can occur if a process or thread, other than the thread or process of the caller, is currently accessing the same driver package as the caller.
ERROR_UNSUPPORTED_TYPE The driver package type is not supported.

Remarks

A caller of DriverPackageUninstall must be a member of the Administrators group; otherwise, the function does not uninstall a driver package and returns ERROR_ACCESS_DENIED.

If the corresponding driver package is signed, the catalog file for the driver package must be in the same directory as the INF file. Otherwise, the uninstall operation will fail and DriverPackageUninstall will return CRYPT_E_FILE_ERROR.

By default, if the specified driver package is associated with an application other than the application that is specified by pInstallerInfo, DriverPackageUninstall removes the association between the driver package and the specified application, does not uninstall the driver package, and returns ERROR_DEPENDENT_APPLICATIONS_EXIST. To force the function to uninstall a driver package even if the package is associated with other applications, the caller can specify the DRIVER_PACKAGE_FORCE flag. However, a caller should use this flag with caution. If a caller forces an uninstall operation, the applications that are associated with the driver package might not function correctly. One possible use of this flag is to remove a driver that is causing the system not to function correctly.

Requirements

Target platform Desktop
Version Available for Microsoft Windows 2000 and later versions of Windows.
Header Difxapi.h (include Difxapi.h)
Library Difxapi.lib

See also

DriverPackageGetPath

DriverPackageInstall

INSTALLERINFO