DismMountImage function
Mounts a WIM or VHD image file to a specified location.
Syntax
HRESULT WINAPI DismMountImage(
_In_ PCWSTR ImageFilePath,
_In_ PCWSTR MountPath,
_In_ UINT ImageIndex,
_In_opt_ PCWSTR ImageName,
_In_ DismImageIdentifier ImageIdentifier,
_In_ DWORD Flags,
_In_opt_ HANDLE CancelEvent,
_In_opt_ DISM_PROGRESS_CALLBACK Progress,
_In_opt_ PVOID UserData
);
Parameters
ImageFilePath [in]
The path to the WIM or VHD file on the local computer. A .wim, .vhd, or .vhdx file name extension is required.
MountPath [in]
The path of the location where the image should be mounted. This mount path must already exist on the computer. The Windows image in a .wim, .vhd, or .vhdx file can be mounted to an empty folder on an NTFS formatted drive. A Windows image in a .vhd or .vhdx file can also be mounted to an unassigned drive letter. You cannot mount an image to the root of the existing drive.
ImageIndex [in]
The index of the image in the WIM file that you want to mount. For a VHD file, you must specify an index of 1
.
ImageName [in, optional]
Optional. The name of the image that you want to mount.
ImageIdentifier [in]
A DismImageIdentifier enumeration value such as DismImageIndex.
Flags [in]
The mount flags to use for this operation. For more information about mount flags, see DISM API Constants.
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 function.
UserData [in, optional]
Optional. User defined custom data.
Return value
Returns S_OK on success.
Returns E_INVALIDARG if any of the paths are not well-formed or if MountPath or ImageFilePath does not exist or is invalid.
Returns a Win32 error code mapped to an HRESULT for other errors.
Remarks
After mounting an image, use DismOpenSession to start a servicing session. For more information, see Using the DISM API.
Mounting an image from a WIM or VHD file that is stored on the network is not supported. You must specify a file on the local computer.
To mount an image from a VHD file, you must specify an ImageIndex of 1
.
The MountPath must be a file path that already exists on the computer. Images in WIM and VHD files can be mounted to an empty folder on an NTFS formatted drive. You can also mount an image from a VHD file to an unassigned drive letter. You cannot mount an image to the root of the existing drive.
When mounting an image in a WIM file, the image can either be identified by the image index number specified by ImageIndex, or the name of the image specified by ImageName. ImageIdentifier specifies whether to use the ImageIndex or ImageName parameter to identify the image.
Example
HRESULT hr = S_OK;
hr = DismMountImage(L” C:\\test\\images\\myimage.wim”, L"C:\\test\\offline", 1, NULL, DismImageIndex, DISM_MOUNT_READWRITE, NULL, NULL, NULL);
Requirements
Requirement | Description |
---|---|
Supported host platforms for .wim files | 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 host platforms for .vhd and .vhdx files | 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 |