MsiSetTargetPath Function

Windows Installer

MsiSetTargetPath Function

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

Syntax

C++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

VersionWindows 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
HeaderMsiquery.h
LibraryMsi.lib
DLLMsi.dll
Unicode and ANSI namesMsiSetTargetPathW (Unicode) and MsiSetTargetPathA (ANSI)

See Also

Installer Location Functions

Send comments about this topic to Microsoft

Build date: 8/13/2009

© 2009 Microsoft Corporation. All rights reserved.