SetupGetSourceFileLocation

The SetupGetSourceFileLocation function retrieves the location of a source file listed in an INF file.

BOOL SetupGetSourceFileLocation(
  HINF InfHandle,      // handle of an INF file
  PINFCONTEXT InfContext,  // optional, context of an INF file
  PCTSTR FileName,     // optional, source file to locate
  PUINT SourceId,      // receives the source media ID
  PTSTR ReturnBuffer,  // optional, receives the location
  DWORD ReturnBufferSize,  // size of the supplied buffer
  PDWORD Required Size // optional, buffer size needed
);
 

Parameters

InfHandle
Handle of the INF file that contains the SourceDisksNames and SourceDisksFiles sections. If platform-specific sections exist for the user's system (for example, SourceDisksNames.mips and SourceDisksFiles.mips), the platform-specific section will be used.
InfContext
This optional parameter points to the context of a line in a Copy Files section for which the full source path is to be retrieved. If this parameter is NULL, FileName is searched for in the SourceDisksFiles section of the INF file specified by InfHandle.
FileName
This optional parameter points to a null-terminated string containing the filename (no path) for which to return the full source location. Either this parameter or InfContext must be specified.
SourceId
Points to a caller-supplied variable that receives the source identifier of the media where the file is located from the SourceDisksNames section of the INF file.
ReturnBuffer
This optional parameter points to a caller-supplied buffer to receive the relative source path. The source path does not include the filename itself, nor does it include a drive letter/network share name. The path does not start or end with a backslash (\), so the empty string specifies the root directory.
ReturnBufferSize
Specifies the size of the buffer pointed to by ReturnBuffer.
RequiredSize
This optional parameter points to a caller-supplied variable that receives the required size for the buffer pointed to by the ReturnBuffer parameter. If the required size is larger than the value specified by ReturnBufferSize, the function fails and GetLastError returns ERROR_INSUFFICIENT_BUFFER.

Return Values

If the function succeeds, the return value is a non-zero value.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

For the Unicode version of this function, the buffer sizes ReturnBufferSize, and ReturnBufferSize are specified in number of characters. This number includes the null terminator. For the ANSI version of this function, the sizes are specified in number of bytes.

If this function is called with a ReturnBuffer of NULL and a ReturnBufferSize of zero, the function puts the buffer size needed to hold the specified data into the variable pointed to by RequiredSize. If the function succeeds in this, the return value is a non-zero value. Otherwise, the return value is zero and extended error information can be obtained by calling GetLastError.

Thus, you can call the function once to get the required buffer size, allocate the necessary memory, and then call the function a second time to retrieve the data. Using this technique, you can avoid errors due to an insufficient buffer size.

QuickInfo

  Windows NT: Use version 4.0 and later.
  Windows: Use Windows 95 and later.
  Windows CE: Unsupported.
  Header: Declared in setupapi.h.
  Import Library: Link with setupapi.lib.

See Also

Overview, Functions, SetupGetSourceInfo, SetupGetSourceFileSize