MsiSetTargetPath function

The MsiSetTargetPath function sets the full target path for a folder in the Directory table.

Syntax


UINT MsiSetTargetPath(
  _In_  MSIHANDLE hInstall,
  _In_  LPCTSTR szFolder,
  _In_  LPCTSTR szFolderPath
);

Parameters

hInstall [in]

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

szFolder [in]

Specifies the folder identifier. This is a primary key in the Directory table.

szFolderPath [in]

Specifies the full path for the folder, ending in a directory separator.

Return value

The MsiSetTargetPath 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_SUCCESS

The function succeeded.

Remarks

The MsiSetTargetPath function changes the path specification for the target directory named in the in-memory Directory table. Also, the path specifications of all other path objects in the table that are either subordinate or equivalent to the changed path are updated to reflect the change. The properties for each affected path are also updated.

MsiSetTargetPath fails if the selected directory is read only.

If an error occurs in this function, all updated paths and properties revert to their previous values. Therefore, it is safe to treat errors returned by this function as nonfatal.

Do not attempt to configure the target path if the components using those paths are already installed for the current user or for a different user. Check the ProductState property before calling MsiSetTargetPath to determine if the product containing this component is installed.

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

MsiSetTargetPathW (Unicode) and MsiSetTargetPathA (ANSI)

See also

Installer Location Functions

 

 

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.