This topic has not yet been rated - Rate this topic

MsiApplyPatch function

Applies to: desktop apps only

For each product listed by the patch package as eligible to receive the patch, the MsiApplyPatch function invokes an installation and sets the PATCH property to the path of the patch package.

Syntax

UINT MsiApplyPatch(
  __in  LPCTSTR szPatchPackage,
  __in  LPCTSTR szInstallPackage,
  __in  INSTALLTYPE eInstallType,
  __in  LPCTSTR szCommandLine
);

Parameters

szPatchPackage [in]

A null-terminated string specifying the full path to the patch package.

szInstallPackage [in]

If eInstallType is set to INSTALLTYPE_NETWORK_IMAGE, this parameter is a null-terminated string that specifies a path to the product that is to be patched. The installer applies the patch to every eligible product listed in the patch package if szInstallPackage is set to null and eInstallType is set to INSTALLTYPE_DEFAULT.

If eInstallType is INSTALLTYPE_SINGLE_INSTANCE, the installer applies the patch to the product specified by szInstallPackage. In this case, other eligible products listed in the patch package are ignored and the szInstallPackage parameter contains the null-terminated string representing the product code of the instance to patch. This type of installation requires the installer running Windows Server 2003 or Windows XP.

eInstallType [in]

This parameter specifies the type of installation to patch.

Type of installationMeaning
INSTALLTYPE_NETWORK_IMAGE

Specifies an administrative installation. In this case, szInstallPackage must be set to a package path. A value of 1 for INSTALLTYPE_NETWORK_IMAGE sets this for an administrative installation.

INSTALLTYPE_DEFAULT

Searches system for products to patch. In this case, szInstallPackage must be 0.

INSTALLTYPE_SINGLE_INSTANCE

Patch the product specified by szInstallPackage. szInstallPackage is the product code of the instance to patch. This type of installation requires the installer running Windows Server 2003 or Windows XP with SP1. For more information see, Installing Multiple Instances of Products and Patches.

 

szCommandLine [in]

A null-terminated string that specifies command line property settings. See About Properties and Setting Public Property Values on the Command Line. See the Remarks section.

Return value

ValueMeaning
ERROR_SUCCESS

The function completed successfully.

ERROR_PATCH_PACKAGE_OPEN_FAILED

Patch package could not be opened.

ERROR_PATCH_PACKAGE_INVALID

The patch package is invalid.

ERROR_PATCH_PACKAGE_UNSUPPORTED

The patch package is unsupported.

An error relating to an action

See Error Codes.

Initialization Error

An initialization error occurred.

 

Remarks

Because the list delimiter for transforms, sources, and patches is a semicolon, this character should not be used for file names or paths.

Note  

You must set the REINSTALL property on the command line when applying a small update or minor upgrade patch. Without this property, the patch is registered on the system but cannot update files. For patches that do not use a Custom Action Type 51 to automatically set the REINSTALL and REINSTALLMODE properties, the REINSTALL property must be explicitly set with the szCommandLine parameter. Set the REINSTALL property to list the features affected by the patch, or use a practical default setting of "REINSTALL=ALL". The default value of the REINSTALLMODE property is "omus". Beginning with Windows Installer version 3.0, the REINSTALL property is configured by the installer and does not need to be set on the command line.

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. See the Windows Installer Run-Time Requirements for information about the minimum Windows service pack that is required by a Windows Installer version.

Header

Msi.h

Library

Msi.lib

DLL

Msi.dll

Unicode and ANSI names

MsiApplyPatchW (Unicode) and MsiApplyPatchA (ANSI)

See also

Error Codes
Initialization Error
Multiple-Package Installations
Not Supported in Windows Installer 2.0 and earlier

 

 

Send comments about this topic to Microsoft

Build date: 2/3/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
C# syntax
[DllImport("msi.dll", CharSet=CharSet.Unicode)]
public static extern uint MsiApplyPatch(string szPatchPackage, string szInstallPackage, int eInstallType, string szCommandLine);
vb.net syntax
<DllImport("msi.dll", CharSet:=CharSet.Unicode)> _
Public Shared Function MsiApplyPatch(ByVal szPatchPackage As String, ByVal szInstallPackage As String, ByVal eInstallType As Integer, ByVal szCommandLine As String) As UInt32
End Function
Hex Values for Win32 error codes Published as part of Open Protocol Specifications

As a part of the Open Protocol Specifications, the hex values for Win32 error codes can now be found at http://msdn2.microsoft.com/en-us/library/cc231199.aspx.