IVMVirtualMachine::AddHardDiskConnection method

Windows Virtual PC

[Windows Virtual PC is no longer available for use as of Windows 8. Instead, use the Hyper-V WMI provider (V2).]

Adds a new hard disk connection to the virtual machine (VM).

Syntax


HRESULT AddHardDiskConnection(
  [in]          BSTR                  hardDiskPath,
  [in]          long                  busNumber,
  [in]          long                  deviceNumber,
  [out, retval] IVMHardDiskConnection **hardDiskConnection
);

Parameters

hardDiskPath [in]

The full path of the virtual hard disk (VHD) file to connect.

busNumber [in]

The bus to which the drive will be attached.

ValueMeaning
0

The drive will be attached to the first bus.

1

The drive will be attached to the second bus.

 

deviceNumber [in]

The device to which the drive will be attached.

ValueMeaning
0

The drive will be attached to the first device on the bus.

1

The drive will be attached to the second device on the bus.

 

hardDiskConnection [out, retval]

An IVMHardDiskConnection object.

Return value

This method can return one of these values.

Return code/valueDescription
S_OK
0

The operation was successful.

E_POINTER
0x80004003

The hardDiskConnection parameter is NULL.

E_INVALIDARG
0x80000003

A hardDiskPath parameter is NULL or the busNumber or deviceNumber parameter is not valid.

HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)
0x80070002

The system cannot find the file specified by the hardDiskPath parameter.

HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)
0x80070003

The system cannot find the path specified by the hardDiskPath parameter.

HRESULT_FROM_WIN32(ERROR_INVALID_NAME)
0x8007007b

The hardDiskPath parameter contains an invalid character (one of "*?<>/|":").

HRESULT_FROM_WIN32(ERROR_BAD_PATHNAME)
0x800700a1

The hardDiskPath parameter specifies an empty or relative path. An absolute path is required.

HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW)
0x8007006f

The path specified by the hardDiskPath parameter is too long. The path must be less than 260 characters.

VM_E_VM_UNKNOWN
0xA0040207

The configuration is unknown.

VM_E_VM_RUNNING_OR_SAVED
0xA004020B

The VM is in a running or saved state.

VM_E_DRIVE_BUS_LOC_IN_USE
0xA00400503

The specified bus location is in use.

VM_E_INVALID_HD_FILE
0xA0040682

The VHD is greater than 127 GB and cannot be connected to the IDE bus.

VM_E_UNSUPPORTED_HD_DISK_TYPE
0xA00400686

The hardDiskPath parameter refers to a linked VHD or a differencing VHD to a linked VHD. Linked VHDs cannot be attached to virtual machines.

HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION)
0x80070020

The specified VHD is already connected to another bus location for this VM.

DISP_E_EXCEPTION
0x80020009

An unexpected error has occurred.

 

Remarks

You can only add a new hard disk connection to a stopped virtual machine.

Requirements

Minimum supported client

Windows 7 [desktop apps only]

Minimum supported server

None supported

End of client support

Windows 7

Product

Windows Virtual PC

Header

VPCCOMInterfaces.h

IID

IID_IVMVirtualMachine is defined as f7092aa1-33ed-4f78-a59f-c00adfc2edd7

See also

IVMVirtualMachine

 

 

Community Additions

ADD
Show: