Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Note
Beginning with the refreshed version of the HLK (updated February 2026), the AddDriver and AddReplacementDriver methods will include a new check for files in the driver package that were not referenced by an .inf file. This information will be available through warningMessages. There will also be new AddDriver and AddReplacementDriver overloads that expose the unreferenced file information through output arguments in addition to warningMessages.
This method adds driver files to the submission package and checks the driver package for driver signability. This method can only be used for submission packages. It cannot be used for update packages. The signability tests are done when drivers are added to the package. If the signability tests fail the driver is not added to the package. Down level operating system signability tests are automatically run. Errors from these signability results will not prevent submission creation (will not cause a false return value). The error messages for down level operating system signability runs will be captured and returned as warnings.
This method also checks for unreferenced files, and generates a log listing all unreferenced and referenced files. If the driver package has at least one unreferenced file, a path to the unreferenced file log is appended to warningMessages.
Namespace: Microsoft.Windows.Kits.Hardware.ObjectModel.Submission
Assembly: Microsoft.Windows.Kits.Hardware.ObjectModel.Submission (in Microsoft.Windows.Kits.Hardware.ObjectModel.Submission)
Usage
Visual Basic
Dim instance As PackageWriter
Dim pathToDriver As String
Dim pathToSymbols As String
Dim targets As ReadOnlyCollection(Of Target)
Dim locales As ReadOnlyCollection(Of String)
Dim errorMessages As StringCollection
Dim warningMessages As StringCollection
Dim returnValue As Boolean
returnValue = instance.AddDriver(pathToDriver, pathToSymbols, targets, locales, errorMessages, warningMessages)
Syntax
Visual Basic
Public Function AddDriver ( _
pathToDriver As String, _
pathToSymbols As String, _
targets As ReadOnlyCollection(Of Target), _
locales As ReadOnlyCollection(Of String), _
<OutAttribute> ByRef errorMessages As StringCollection, _
<OutAttribute> ByRef warningMessages As StringCollection _
) As Boolean
C#
public bool AddDriver (
string pathToDriver,
string pathToSymbols,
ReadOnlyCollection<Target> targets,
ReadOnlyCollection<string> locales,
out StringCollection errorMessages,
out StringCollection warningMessages
)
Parameters
pathToDriver
The path to the driver files. All files in this directory and all subdirectories will be packaged.
pathToSymbols
The path to the symbol files for this driver. This parameter is optional.
targets
The set of supported test targets for this driver.
locales
The set of supported locales for this driver.
errorMessages
A reference to a string collection that contains all the error messages for the submission package.
warningMessages
A reference to a string collection that contains all the warning messages for the submission package (including unreferenced file check).
Return Value
true if the signability tests passed and the driver was added to the package; otherwise, false.
Remarks
An exception is thrown when:
The pathToDriver paramter, the targets parameter or the locales parameter is null.
The pathToDrivers parameter is empty or there are no targets or locales values in the parameter lists or the targets specified do not exist in the project.
The directory does not exist for the pathToDriver parameter or the pathToSymbol parameter.
The PackageWriter object has already been disposed.
The method calls an invalid connection type.
Notes on unreferenced file check:
If there is at least one unreferenced file, the following text will appear in warningMessages: "There was at least one file in the driver package that was not referenced by an .inf. Please only include files that are referenced by an .inf in the driver package. Refer to HLK's Microsoft Learn pages online for more information. For full list of unreferenced files in this package, see {log path}"
If the unreferenced file check failed to complete, the following text will appear in warningMessages: "Failed to analyze driver package for unreferenced files: {exception message}" This does not indicate whether the attached files were referenced or not, just that the check was not able to properly run.
If all attached files were properly referenced, warningMessages will not contain any messages pertaining to the unreferenced file check.
Every time AddDriver is run, a new log is generated (located at {drive letter}\HLK\JobsWorkingDir\UnreferencedFileLogs\UnreferencedFiles_{timestamp}.txt), even if all attached files were referenced.
The unreferenced file check supports most compressed files.
If a file is compressed and its extension ends in “_”, there will be no unreferenced file warning so long as the decompressed version of the file is properly referenced by the .inf.
If a .cab is included as a source location in the .inf’s SourceDisksNames section, HLK will examine the .cab’s contents during the unreferenced file check.
If a .cab is referenced as a driver file in the .inf, it will be treated as such during the unreferenced file check, and the .cab’s contents will not be examined.
What is not supported:
Attaching compressed .cat files.
Attaching double-compressed files (e.g. A user compresses a file individually, and then packs the already-compressed file into a cab. Or a user compresses files into a .cab, and then compresses the .cab a second time so it now ends with an underscore).
For info on log format and how to retrieve the list of unreferenced files, see Creating a Package. For tips on resolving unreferenced file warning, see Add driver and supplemental content to your package.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.