Retrieving and Using the Path of a DIFx Driver Store INF File

An application can use the DriverPackageGetPath function to retrieve the path of the INF file for a driver package that is preinstalled in the DIFx driver store. This type of INF file is referred to as a DIFx driver store INF file.

An application can save the path of a DIFx driver store INF file in a persistent store (for example, as a registry entry). The application can then call DriverPackageUninstall to uninstall the driver package that is associated with the DIFx driver store INF file path that was saved. By retrieving and saving the path of a DIFx driver store INF file, an installation application does not have to subsequently supply a copy of the INF file to uninstall the driver package. The path of a DIFx driver store INF file remains valid as long as the driver package is preinstalled.

To retrieve the path of a DIFx driver store INF file for a preinstalled driver package, an installation application calls the DriverPackageGetPath function and supplies the following:

  • A pointer in DriverPackageInfPath to a string that supplies the fully qualified path of an INF file of a driver package for which to retrieve the corresponding path of a DIFx driver store INF file. For more information about supplying an INF file path, see Specifying a Driver Package INF File.

  • A pointer in pDestInfPath to an output buffer that receives a NULL-terminated string that contains the path of a DIFx driver store INF file.

  • A pointer in pNumOfChars to an output variable that receives the length of the path, in characters, of the NULL-terminated string that contains the path of a DIFx driver store INF file.

To retrieve the path of a DIFx driver store INF file

To retrieve the path of an INF file in the DIFx driver store, do the following:

  1. Obtain the number of bytes necessary to store the DIFx driver store INF file path by calling DriverPackageGetPath with DriverPackageInfPath set to the path of an INF file that is a copy of the DIFx driver store INF file, pDestInfPath set to NULL, and *pNumOfChars set to zero.

  2. Call DriverPackageGetPath again, supplying the same INF file path as in step 1 and an output buffer that is large enough to retrieve the DIFx driver store INF file path.

The following code example demonstrates step 1 to retrieve the path of a DIFx driver store INF file whose driver package's INF file is D:\Directory\SomeINFfile.inf.


#define UNICODE
#include "difxapi.h"
. . .
PTCHAR DriverPackageInfPath = TEXT("d:\\directory\\SomeINFfile.inf");
DWORD NumOfChars = 0;
DWORD ReturnCode = ERROR_SUCCESS;
 
// Call DriverPackageGetPath to retrieve the 
// length, in characters, of the requested path of the 
// DIFx driver store INF file
// The function returns the required length in NumOfChars
ReturnCode = DriverPackageGetPath( DriverPackageInfPath, NULL, &NumOfChars );

In response to this call, DriverPackageGetPath returns ERROR_INSUFFICIENT_BUFFER and sets NumOfChars to the required buffer size, in characters, for the output buffer.

The following code example demonstrates step 2. In this step, DriverPackageGetPath is called again with a buffer that is large enough to hold the number of characters that was returned in NumOfChars.


// Allocate an output buffer to retrieve the DIFx driver store INF file path
PTCHAR DriverStoreInfPath = (PTCHAR) LocalAlloc(LPTR, NumOfChars * sizeof(TCHAR));
. . .
// Retrieve the DIFx driver store INF path
ReturnCode = DriverPackageGetPath( DriverPackageInfPath, DriverStoreInfPath, &NumOfChars));

If this call to DriverPackageGetPath succeeds, the function returns ERROR_SUCCESS. Otherwise, the function did not retrieve the request path and returns an error code that indicates the cause of the failure. Some common return values that indicate that the operation failed include the following:

ERROR_DRIVER_PACKAGE_NOT_IN_STORE

There is no DIFx driver store INF file that corresponds to the specified INF file.

ERROR_FILE_NOT_FOUND

The INF file that was specified by DriverPackageInfPath was not found.

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft