Share via


UnmountVHD function

Unmounts a virtual hard disk file (.vhd file) that had been mounted with the MountVHD function.

Syntax

ULONG WINAPI UnmountVHD(
  _In_ PWCHAR VHDFileName,
  _In_ ULONG  Flags
);

Parameters

VHDFileName [in]

A pointer to a null-terminated Unicode string that specifies the full path to the VHD file. Relative paths to the VHD file are not supported.

Flags [in]

This parameter is reserved. Use VHD_NORMAL (0).

Value Meaning
VHD_NORMAL
0
Unmount the VHD file normally.
VHD_FORCE_UNMOUNT
3
Force the system to unmount the VHD file without sending any device eject notification. This could result in a message being logged in the event viewer and data loss and corruption on the mounted file.

Return value

On successful call, the return value is ERROR_SUCCESS (0). Any of the system error codes can be returned. Common return values include the following.

Return code/value Description
ERROR_INVALID_DATA
13 (0xD)
A value other than VHD_NORMAL (0) or VHD_FORCE_UNMOUNT (3) was passed in the Flags parameter.
ERROR_DEV_NOT_EXIST
55 (0x37)
An error occurred while unmounting the file.
ERROR_DEVICE_IN_USE
2404 (0x964)
The device is in use and cannot be unmounted. Passing VHD_FORCE_UNMOUNT in the Flags parameter can force the file to unmount.

Requirements

Download
Microsoft Virtual Server 2005 R2 SP1 Update onWindows Server 2008orWindows Server 2003
Header
VHDMount.h
Library
VHDMount.lib
DLL
VHDMount.dll

See also

Virtual Server Functions

MountVHD

VHD_FLAGS