Collapse the table of content
Expand the table of content

SetupGetSourceFileLocation function

[This function is available for use in the operating systems indicated in the Requirements section. It may be altered or unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]

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


BOOL SetupGetSourceFileLocation(
  _In_     HINF InfHandle,
  _In_     PINFCONTEXT InfContext,
  _In_     PCTSTR FileName,
  _Inout_  PUINT SourceId,
  _Inout_  PTSTR ReturnBuffer,
  _Out_    DWORD ReturnBufferSize,
  _Inout_  PDWORD RequiredSize


InfHandle [in]

Handle to the INF file that contains the SourceDisksNames and SourceDisksFiles sections. If platform-specific sections exist for the user's system (for example, SourceDisksNames.x86 and SourceDisksFiles.x86), the platform-specific section will be used.

InfContext [in]

Optional pointer 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 [in]

Optional pointer to a null-terminated string containing the filename (no path) for which to return the full source location. This parameter can be NULL, but either FileName or InfContext must be specified.

SourceId [in, out]

Pointer to a variable that receives the source identifier of the media where the file is located from the SourceDisksNames section of the INF file.

ReturnBuffer [in, out]

Optional pointer to a 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. You should use a null-terminated string buffer. The null-terminated string should not exceed the size of the destination buffer. 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. See the Remarks section. This parameter can be NULL.

ReturnBufferSize [out]

Size of the buffer pointed to by ReturnBuffer, in characters. This number includes the null terminator.

RequiredSize [in, out]

Optional pointer to a variable that receives the required size for the buffer pointed to by the ReturnBuffer parameter, in characters. This number includes the null terminator. If the required size is larger than the value specified by ReturnBufferSize, the function fails and GetLastError returns ERROR_INSUFFICIENT_BUFFER.

Return value

If the function succeeds, the return value is a nonzero value.

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


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 nonzero value. Otherwise, the return value is zero and extended error information can be obtained by calling GetLastError.


Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]







Unicode and ANSI names

SetupGetSourceFileLocationW (Unicode) and SetupGetSourceFileLocationA (ANSI)

See also




Community Additions

© 2016 Microsoft