Name

CreatePropertyList

Description

HRESULT
CreatePropertyList([out] IPropertyList** newPropertyList,
                   [out,retval] ULONGLONG* error)

Creates a property list. Property lists are useful for passing extra parameters to functions such as host.OpenVM.

See also: propertylist.GetProperty and propertylist.SetProperty.

Parameters

newPropertyList
This contains a new IPropertyList object.
error
This returns VIX_OK if the method call succeeded, otherwise the return value indicates an error.

Return Value

HRESULT

Remarks

Side Effects

None.

Requirements

VixCOM.h, since VMware VIX API 1.10.1.

Example

C#
/*
 * This example opens an encrypted VM by specifying the
 * encryption password in a property list.
 */

// Connects to the Workstation Host
IJob connectJob = vix.Connect(Constants.VIX_API_VERSION,
                              Constants.VIX_SERVICEPROVIDER_VMWARE_WORKSTATION,
                              "",
                              0,
                              "",
                              "",
                              0,
                              null,
                              null);

object[] connectProperties = { Constants.VIX_PROPERTY_JOB_RESULT_HANDLE };
object hosts = null;
ulong err = connectJob.Wait(connectProperties, ref hosts);
if (vix.ErrorIndicatesFailure(err))
{
  ((IVixHandle2)connectJob).Close();
  throw new Exception(vix.GetErrorText(err, null));
}

IHost3 host = (IHost3)((object[])hosts)[0];

// Encrypted VM Path
string vmx = "C:\\VMs\\winxpprowithsp2\\winxpprowithsp2.vmx";

// Creates an empty property list
Console.WriteLine("Opening {0}", vmx);
IPropertyList propertyList;
err = host.CreatePropertyList(out propertyList);
if (vix.ErrorIndicatesFailure(err))
{
  ((IVixHandle2)connectJob).Close();
  throw new Exception(vix.GetErrorText(err, null));
}

// Adds a new value to the property list containing the encryption password
propertyList.SetProperty(Constants.VIX_PROPERTY_VM_ENCRYPTION_PASSWORD,
                         "password");

//Open the encrypted VM providing the property list
IJob openJob = host.OpenVMEx(vmx, 0, propertyList, null);
object[] openProperties = { Constants.VIX_PROPERTY_JOB_RESULT_HANDLE };
object openResults = null;

err = openJob.Wait(openProperties, ref openResults);
if (vix.ErrorIndicatesFailure(err))
{
  ((IVixHandle2)openJob).Close();
  throw new Exception(vix.GetErrorText(err, null));
}

Console.WriteLine("Opened {0}", vmx);
IVM2 vm = (IVM2)((object[])openResults)[0];

// Run the rest of your vm operations here

// Close each object to prevent leaks
((IVixHandle2) vm).Close();
propertyList.Close();

host.Disconnect();

Copyright (C) 2007-2011 VMware, Inc. All rights reserved.