The MsiGetSourcePath function returns the full source path for a folder in the Directory table.
Syntax
C++UINT MsiGetSourcePath(
__in MSIHANDLE hInstall,
__in LPCTSTR szFolder,
__out LPTSTR szPathBuf,
__inout DWORD *pcchPathBuf
);
Parameters
- hInstall [in]
-
Handle to the installation provided to a DLL custom action or obtained through MsiOpenPackage, MsiOpenPackageEx, or MsiOpenProduct.
- szFolder [in]
-
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.
- szPathBuf [out]
-
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.
- pcchPathBuf [in, out]
-
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:
- ERROR_DIRECTORY
-
The directory specified was not found in the Directory table.
- ERROR_INVALID_HANDLE
-
An invalid or inactive handle was supplied.
- ERROR_INVALID_PARAMETER
-
An invalid parameter was passed to the function.
- ERROR_MORE_DATA
-
The buffer passed in was too small to hold the entire value.
- ERROR_SUCCESS
-
The function succeeded.
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.
Requirements
Version | Windows Installer 5.0 on 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, Windows XP, and Windows 2000 |
---|---|
Header | Msiquery.h |
Library | Msi.lib |
DLL | Msi.dll |
Unicode and ANSI names | MsiGetSourcePathW (Unicode) and MsiGetSourcePathA (ANSI) |
See Also
Send comments about this topic to Microsoft
Build date: 8/13/2009
© 2009 Microsoft Corporation. All rights reserved.