Share via


IVMVirtualMachine::SetConfigurationValue method

The SetConfigurationValue method sets the value of the specified configuration setting for this virtual machine.

Syntax

HRESULT SetConfigurationValue(
  [in] BSTR    configurationKey,
  [in] VARIANT configurationValue
);

Parameters

configurationKey [in]

Key used to identify the configuration value as stored in the "*.vmc" file.

configurationValue [in]

The configuration value. Variant type may be one of: VT_ARRAY|VT_UI1 (raw bytes), VT_BSTR (string), VT_UI4 (integer), or VT_BOOL (Boolean).

Return value

This method can return one of these values.

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_INVALIDARG
The configurationKey parameter is NULL or empty, the configurationValue parameter is NULL, or the configurationValue parameter is not a valid variant type.
VM_E_VM_UNKNOWN
The configuration is unknown.
DISP_E_EXCEPTION
An unexpected error has occurred.

Remarks

This method provides low-level access to any configuration value. It can be used to set configuration values for customer-defined keys. Be careful if you use this method to set system configuration values, since no error checking is performed on the configuration value. Also, some configuration values cannot be changed while the virtual machine is running.

Configuration keys are located in the virtual machine's "*.vmc" file in XML format. The keys are stored in a hierarchical manner similar to the registry keys in Windows. To specify a specific subkey, a "key path" is constructed which specifies the various keys in a slash mark delimited format.

For example, to set the value of the "ram_size" key located in the following key tree:

<hardware>
    <memory>
        <ram_size type="integer">128</ram_size>

The configurationKey path string would be specified as follows:

"hardware/memory/ram_size"

If any of the keys in the desired tree have an "id" attribute value, the attribute and its value is embedded in the configurationKey path string immediately after its associated configuration key using the following bracketed format: "[@id="id_value"]".

For example, to set the value of the "absolute" key located in the following key tree:

<hardware>
    <pci_bus>
        <ide_adapter>
            <ide_controller id="1">
                <location id="0">
                    <pathname>
                        <absolute type="string">D</absolute>

The configurationKey path string would be specified as follows:

"hardware/pci_bus/ide_adapter/ide_controller[@id=1]/location[@id=0]/pathname/absolute"

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

IVMVirtualMachine