Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

DriverPackageGetPath (difxapi)
 
.
Summary
The DriverPackageGetPath function retrieves the fully qualified path of the driver store INF file for a preinstalled driver package.

C# Signature:

[DllImport("DIFxAPI.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern Int32 DriverPackageGetPath([MarshalAs(UnmanagedType.LPTStr)] string DriverPackageInfPath, [MarshalAs(UnmanagedType.LPTStr)] string pDestInfPath, out Int32 pNumOfChars);

VB Signature:

Public Declare Auto Function DriverPackageGetPath Lib "DIFxAPI.dll" (ByVal DriverPackageInfPath As String, ByVal pDestInfPath As String, ByRef pNumOfChars As Int32) As Int32

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

I was unable to get the C# Signature above to work but this worked fine.

None.

[DllImport("DIFxAPI.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern Int32 DriverPackageGetPath(
    [MarshalAs(UnmanagedType.LPTStr)]
    string DriverPackageInfPath,
    StringBuilder pDestInfPath,
    out Int32 pNumOfChars

Tips & Tricks:

To use this function you just need difxapi.dll of appropriate architecture from Windows Server 2008/Vista WDK. The DriverStore will be created automatically for you.

Please add some!

Sample Code:

C#:

const Int32 ERROR_INSUFFICIENT_BUFFER = 122;
string infFile = <INF_file_name>;
Int32 infDriverStorePathLength = 256;
string infDriverStorePath = String.Empty;
infDriverStorePath = infDriverStorePath.PadLeft(infDriverStorePathLength - 1);
Int32 GetPathResult = DriverPackageGetPath(infFile, infDriverStorePath, out infDriverStorePathLength);
if (GetPathResult == ERROR_INSUFFICIENT_BUFFER)
{
     infDriverStorePath = infDriverStorePath.PadLeft(infDriverStorePathLength-1);
     GetPathResult = DriverPackageGetPath(infFile, infDriverStorePath, out infDriverStorePathLength);
}

VB:

Const ERROR_INSUFFICIENT_BUFFER As Int32 = 122
Dim infFile As String = <INF_file_name>
Dim infDriverStorePathLength As Int32 = 256
Dim infDriverStorePath As String = String.Empty
infDriverStorePath = infDriverStorePath.PadLeft(infDriverStorePathLength - 1)
Dim GetPathResult As Int32 = DriverPackageGetPath(infFile, infDriverStorePath, infDriverStorePathLength)
If GetPathResult = ERROR_INSUFFICIENT_BUFFER Then
     infDriverStorePath = infDriverStorePath.PadLeft(infDriverStorePathLength - 1)
     GetPathResult = DriverPackageGetPath(infFile, infDriverStorePath, infDriverStorePathLength)
End If

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions