MsiGetSourcePathA function (msiquery.h)

The MsiGetSourcePath function returns the full source path for a folder in the Directory table.

Syntax

UINT MsiGetSourcePathA(
  [in]      MSIHANDLE hInstall,
  [in]      LPCSTR    szFolder,
  [out]     LPSTR     szPathBuf,
  [in, out] LPDWORD   pcchPathBuf
);

Parameters

[in] hInstall

Handle to the installation provided to a DLL custom action or obtained through MsiOpenPackage, MsiOpenPackageEx, or MsiOpenProduct.

[in] szFolder

A null-terminated string that specifies a record of the Directory table. If the directory is a root directory, this can be a value from the DefaultDir column. Otherwise it must be a value from the Directory column.

[out] szPathBuf

Pointer to the buffer that receives the null terminated full source path. Do not attempt to determine the size of the buffer by passing in a null (value=0) for szPathBuf. You can get the size of the buffer by passing in an empty string (for example ""). The function then returns ERROR_MORE_DATA and pcchPathBuf contains the required buffer size in TCHARs, not including the terminating null character. On return of ERROR_SUCCESS, pcchPathBuf contains the number of TCHARs written to the buffer, not including the terminating null character.

[in, out] pcchPathBuf

Pointer to the variable that specifies the size, in TCHARs, of the buffer pointed to by the variable szPathBuf. When the function returns ERROR_SUCCESS, this variable contains the size of the data copied to szPathBuf, not including the terminating null character. If szPathBuf is not large enough, the function returns ERROR_MORE_DATA and stores the required size, not including the terminating null character, in the variable pointed to by pcchPathBuf.

Return value

The MsiGetSourcePath function returns the following values:

Remarks

Before calling this function, the installer must first run the CostInitialize action, FileCost action, and CostFinalize action. For more information, see Calling Database Functions from Programs.

If ERROR_MORE_DATA is returned, the parameter which is a pointer gives the size of the buffer required to hold the string. If ERROR_SUCCESS is returned, it gives the number of characters written to the string buffer. Therefore you can get the size of the buffer by passing in an empty string (for example "") for the parameter that specifies the buffer. Do not attempt to determine the size of the buffer by passing in a Null (value=0).

If the function fails, you can obtain extended error information by using MsiGetLastErrorRecord.

Note

The msiquery.h header defines MsiGetSourcePath as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

Requirements

Requirement Value
Minimum supported client Windows Installer 5.0 on Windows Server 2012, Windows 8, Windows Server 2008 R2 or Windows 7. Windows Installer 4.0 or Windows Installer 4.5 on Windows Server 2008 or Windows Vista. Windows Installer on Windows Server 2003 or Windows XP
Target Platform Windows
Header msiquery.h
Library Msi.lib
DLL Msi.dll

See also

Installer Location Functions

Passing Null as the Argument of Windows Installer Functions