[Some information relates to pre-released product which may be substantially modified before it's commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.]
Associates an offline or online Windows image with a DISMSession.
HRESULT WINAPI DismOpenSession( _In_ PCWSTR ImagePath, _In_opt_ PCWSTR WindowsDirectory, _In_opt_ PCWSTR SystemDrive, _Out_ DismSession *Session );
Set ImagePath to one of the following values:
- An absolute or relative path to the root directory of an offline Windows image.
- An absolute or relative path to the root directory of a mounted Windows image. You can mount the image before calling DismOpenSession by using an external tool or by using DismMountImage.
- DISM_ONLINE_IMAGE to associate the Session with the online Windows installation.
WindowsDirectory [in, optional]
Optional. A relative or absolute path to the Windows directory. The path is relative to the mount point.
If the value of WindowsDirectory is NULL, the default value of "Windows" is used.
The WindowsDirectory parameter cannot be used when the ImagePath parameter is set to DISM_ONLINE_IMAGE.
SystemDrive [in, optional]
Optional. The letter of the system drive that contains the boot manager. If SystemDrive is NULL, the default value of the drive containing the mount point is used.
The SystemDrive parameter cannot be used when the ImagePath parameter is set to DISM_ONLINE_IMAGE.
A valid DismSession. The DismSession must be associated with an image. You can associate a session with an image by using the DismOpenSession.
Returns S_OK on success.
HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS) if the DismSession already has an image associated with it.
Returns a Win32 error code mapped to an HRESULT for other errors.
HRESULT hr = S_OK; DismSession Session = DISM_SESSION_DEFAULT; hr = DismOpenSession(L"C:\\Mount\\", NULL, NULL, &Session);
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.
Minimum supported client
Windows 7 [desktop apps only]
Minimum supported server
Windows Server 2008 R2 [desktop apps only]