IVMVirtualServer::CreateVirtualNetwork method

The CreateVirtualNetwork method creates a new virtual network.

Syntax

HRESULT CreateVirtualNetwork(
  [in]  BSTR              virtualNetworkName,
  [in]  BSTR              virtualNetworkPath,
  [out] IVMVirtualNetwork **virtualNetwork
);

Parameters

virtualNetworkName [in]

The name of the new virtual network. The length of the name cannot exceed 256 characters and the combined length of the name and path cannot exceed 260 characters. The file name extension ".vnc" will be appended to the end of the virtual network name when the configuration file is created. If this parameter is NULL or an empty string, the virtualNetworkPath parameter must specify the full path to the configuration file.

virtualNetworkPath [in]

The path to the folder that will contain the configuration file. This folder will be created if it does not exist. If the virtualNetworkName parameter is NULL or an empty string, this must specify the full path the new configuration file.

virtualNetwork [out]

A pointer to a new IVMVirtualNetwork object which represents this virtual network.

Return value

This method supports standard return values, as well as the following. For information on Virtual Server specific return values not listed below, see HRESULT Codes Specific to the Virtual Server.

Return code Description
S_OK
The operation was successful.
E_POINTER
The virtualNetwork parameter is NULL.
E_INVALIDARG
The virtualNetworkName or virtualNetworkPath parameter is not valid or is an empty string.
E_PATH_NOT_FOUND
The system cannot find the path specified by the virtualNetworkName and virtualNetworkPath parameters.
E_INVALID_NAME
The virtualNetworkPath parameter contains a character that is not valid (one of "*?:<>/|"").
E_BAD_PATHNAME
The virtualNetworkPath parameter specifies an empty or relative path. An absolute path is required.
E_BUFFER_OVERFLOW
The path specified by the virtualNetworkName and virtualNetworkPath parameters results is a path that is too long. The total length of the path must be less than 260 characters.
E_ALREADY_EXISTS
A configuration file with this name already exists at this location.
VM_E_CONFIG_NAME_INVALID_CHAR
The virtualNetworkName parameter contains a character that is not valid (one of "*?:<>/|\"").
VM_E_CONFIG_DUPLICATE_NAME
There is already a virtual network with this name.
DISP_E_EXCEPTION
An unexpected error occurred.

Remarks

By default, the adapter of the virtual network is set for guest-only networking, which isolates the virtual machine from the network. Use the IVMVirtualNetwork::HostAdapter method to change the adapter for this virtual network. The name must be unique with respect to the names of any existing virtual networks. Virtual network names are case-insensitive, for example, "MyNetwork" and "mynetwork" refer to the same virtual network.

Requirements

Product
Microsoft Virtual Server 2005 onWindows Server 2003
Download
Microsoft Virtual Server 2005 R2 SP1 Update onWindows Server 2008orWindows Server 2003
Header
VsComInterfaces.h

See also

IVMVirtualServer