Export (0) Print
Expand All
Expand Minimize

MsiGetTargetPath function

The MsiGetTargetPath function returns the full target path for a folder in the Directory table.

Syntax


UINT MsiGetTargetPath(
  _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 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.

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 MsiGetTargetPath 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 supplied.

ERROR_MORE_DATA

The buffer passed in was too small to hold the entire value.

ERROR_SUCCESS

The function succeeded.

Remarks

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).

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.

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.

Requirements

Version

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

Header

Msiquery.h

Library

Msi.lib

DLL

Msi.dll

Unicode and ANSI names

MsiGetTargetPathW (Unicode) and MsiGetTargetPathA (ANSI)

See also

Installer Location Functions
Passing Null as the Argument of Windows Installer Functions

 

 

Community Additions

ADD
Show:
© 2014 Microsoft