Hi,
I am trying to cast from one object type to another type. Which is ISnapshot to
IVixHandle.
My code:
#Dispach + connecting to lib and getting a handle to a VM
root = vmHandle.GetRootSnapshot(0)[1]
rootC = root.GetChild(0)[1]
ivixHandle = win32com.client.CastTo(rootC, 'IVixHandle')
name = ivixHandle.GetProperties([CONST.VIX_PROPERTY_SNAPSHOT_DISPLAYNAME],
None)
Result:
Traceback (most recent call last):
File "Z:\prototype.py", line 20
s = ivixHandle.GetProperties([CONST.VIX_PROPERTY_SNAPSHOT_DISPLAYNAME], None)
File
"C:\Users\vinaya\AppData\Local\Temp\gen_py\2.4\7A474EE3-0062-4239-AE91-134AC9BD5FD3x0x1x0.py",
line 1269, in GetProperties
, propertiesArray)
File "C:\Python24\lib\site-packages\win32com\client\__init__.py", line 446,
in _ApplyTypes_
return self._get_good_object_(
pywintypes.com_error: (-2147352571, 'Type mismatch.', None, 1)
The signature of the method is:
HRESULT GetProperties([in] VARIANT propertyIDs, [in,out] VARIANT*
propertiesArray, [out,retval] ULONGLONG* error);
The
documentation(http://www.vmware.com/support/developer/vix-api/vix16_reference/lang/com/functions/GetProperties.html)
says this:
This function does not apply in VBScript, since it is not possible to access
the IVixHandle interface of an object.
Also, this is the way to code(using another handle which is castable to
IVixHandle) in C#:
VixCOM.IVM vm;
UInt64 err;
// ...Open the virtual machine and get a handle...
int[] propertyIDs = new int[] {VixCOM.Constants.VIX_PROPERTY_VM_POWER_STATE,
VixCOM.Constants.VIX_PROPERTY_VM_VMX_PATHNAME};
object properties = null;
err = ((VixCOM.IVixHandle)vm).GetProperties(propertyIDs, ref properties);
if (lib.ErrorIndicatesFailure(err)) {
// Handle the error...
}
int vmPowerState = ((object[])properties)[0]; //
VixCOM.Constants.VIX_PROPERTY_VM_POWER_STATE
string vmPathName = ((object[])properties)[1]; //
VixCOM.Constants.VIX_PROPERTY_VM_VMX_PATHNAME
Is there anyway I can get access to this functionality?
Thanks,
Vinay A.
_______________________________________________
python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32