DismAddDriver Function

Adds a third party driver (.inf) to an offline Windows® image.

HRESULT WINAPI DismAddDriver (
    _In_ DismSession Session,
    _In_ PCWSTR DriverPath,
    _In_ BOOL ForceUnsigned,
);

Parameters

Parameter Name Description

Session

A valid DISM Session. The DISM Session must be associated with an image. You can associate a session with an image by using the DismOpenSession Function.

DriverPath

A relative or absolute path to the driver .inf file.

ForceUnsigned

A Boolean value that specifies whether to accept unsigned drivers to an x64-based image. Unsigned drivers will automatically be added to an x86-based image.

 

TRUE

Add unsigned drivers to an x64-based image.

FALSE

Do not add unsigned drivers to an x64-based image.

Return Value

Returns S_OK on success.

Remarks

This function is only supported for offline images.

Warning

Removing a boot-critical driver can make the offline Windows image unbootable.

Example

In this example, the driver being added is located on the technician computer in the folder C:\drivers\. The driver has the filename usb.inf on the technician computer, but is renamed to "OEM1.inf" or "OEM2.inf" in the target image. The numbering of the OEMx.inf files is dependent on the number of drivers added. The new name, for example OEM1.inf, is returned in the DismDriverPackage Structure when you call the DismGetDrivers Function. You should use the new name, OEM1.inf, to specify the DriverPath when you use the DismGetDriverInfo Function.

HRESULT hr = S_OK;

hr = DismAddDriver(Session, L"C:\\Drivers\\usb.inf", FALSE);

Requirements

Supported host platforms:

DISM API can be used on any operating system supported by the Windows® Assessment and Deployment Kit (Windows ADK). For more information, see the Windows ADK Technical Reference.

Supported image platforms:

Windows® 7, Windows Server® 2008 R2, Windows PE 3.0, Windows® 8, Windows Server® 2012, Windows® Preinstallation Environment (Windows PE) 4.0

See Also

Reference

DismGetDriverInfo Function
DismGetDrivers Function
DismRemoveDriver Function