The MsiGetTargetPath function returns the full target path for a folder in the Directory table.
UINT MsiGetTargetPathA( MSIHANDLE hInstall, LPCSTR szFolder, LPSTR szPathBuf, LPDWORD pcchPathBuf );
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.
Pointer to the buffer that receives the null terminated full target 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.
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.
The MsiGetTargetPath function returns the following values:
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).
MsiGetTargetPath returns the default path of the target directory authored in the package if the target's current location is unavailable for an installation. For example, if during a Maintenance Installation a target directory at a network location is unavailable, the installer resets the target directory paths back to their defaults. To get the actual path of the target directory in this case call MsiProvideComponent for a component that is known to have been previously installed into the searched for directory and set dwInstallMode to INSTALLMODE_NODETECTION.
For more information, see Calling Database Functions From Programs.
If the function fails, you can obtain extended error information by using MsiGetLastErrorRecord.
|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|