Jaa


DismAddPackage function

Adds a single .cab or .msu file to a Windows image.

Syntax

HRESULT WINAPI DismAddPackage(
  _In_     DismSession            Session,
  _In_     PCWSTR                 PackagePath,
  _In_     BOOL                   IgnoreCheck,
  _In_     BOOL                   PreventPending,
  _In_opt_ HANDLE                 CancelEvent,
  _In_opt_ DISM_PROGRESS_CALLBACK Progress,
  _In_opt_ PVOID                  UserData
);

Parameters

Session [in]
A valid DismSession. The DismSession must be associated with an image. You can associate a session with an image by using the DismOpenSession.

PackagePath [in]
A relative or absolute path to the .cab or .msu file being added, or a folder containing the expanded files of a single .cab file.

IgnoreCheck [in]
A Boolean value to specify whether to ignore the internal applicability checks that are done when a package is added.

Value Description
TRUE Ignore the internal applicability checks.
FALSE Do not ignore the internal applicability checks.

PreventPending [in]
A Boolean value to specify whether to add a package if it has pending online actions.

Value Description
TRUE Prevent the installation of a package that has pending online actions.
FALSE Allow the installation of a package that has pending online actions.

CancelEvent [in, optional]
Optional. You can set a CancelEvent for this function in order to cancel the operation in progress when signaled by the client. If the CancelEvent is received at a stage when the operation cannot be canceled, the operation will continue and return a success code. If the CancelEvent is received and the operation is canceled, the image state is unknown. You should verify the image state before continuing or discard the changes and start again.

Progress [in, optional]
Optional. A pointer to a client-defined DismProgressCallback.

UserData [in, optional]
Optional. User defined custom data.

Return value

If the function succeeds, the return value is S_OK. The function may also return one of the following values when it succeeds:

Return code Description
(HRESULT)ERROR_SUCCESS_REBOOT_REQUIRED
If the Session is online, the computer needs to be restarted.
DISMAPI_S_RELOAD_IMAGE_SESSION_REQUIRED
The Session needs to be reloaded.

If the function fails, the return value is an HRESULT error value.

Remarks

Only .cab files can be added to an online image. Either .cab or .msu files can be added to an offline image.

This function will return a special error code if the package is not applicable. You can use the DismGetPackageInfo to determine if a package is applicable to the target image.

Example

HRESULT hr = S_OK;
hr = DismAddPackage(Session, "C:\\packages\\calc.cab", FALSE, FALSE, NULL, NULL, NULL);

Requirements

Requirement Description
Supported host platforms DISM API can be used on any operating system supported by the Windows Assessment and Deployment Kit (Windows ADK). For more information, see the Windows ADK Technical Reference.
Supported image platforms Windows 7, Windows Server 2008 R2, Windows PE 3.0, Windows 8, Windows Server 2012, Windows Preinstallation Environment (Windows PE) 4.0, Windows 8.1, Windows Server 2012 R2, Windows 10, Windows Server 2016
Minimum supported client Windows 7 [desktop apps only]
Minimum supported server Windows Server 2008 R2 [desktop apps only]
Header DismAPI.h
Library DismAPI.lib
DLL DismAPI.dll

See also

DismAddDriver

DismEnableFeature

DismGetPackages

DismGetPackageInfo

DismRemovePackage

DismPackage

DismPackageInfo

DismPackageFeatureState