[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);
Public Declare Auto Function DriverPackageGetPath Lib "DIFxAPI.dll" (ByVal DriverPackageInfPath As String, ByVal pDestInfPath As String, ByRef pNumOfChars As Int32) As Int32
None.
Do you know one? Please contribute it!
I was unable to get the C# Signature above to work but this worked fine.
[DllImport("DIFxAPI.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern Int32 DriverPackageGetPath(
[MarshalAs(UnmanagedType.LPTStr)]
string DriverPackageInfPath,
StringBuilder pDestInfPath,
out Int32 pNumOfChars
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.
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