views:

65

answers:

1

Hi:

I am programing VIX API from python 2.5, but now I want to port the code to python 3.2

This funtion opens the virtual machine:

        self.jobHandle = self.VixLib.vix.VixVM_Open(self.hostHandle,
                                "C:\\MyVirtualMachine.vmx",
                                None,
                                None)enter code here

Previusly this function is imported from Vix.dll with this code:

vix.VixVM_Open.restype = VixHandle
vix.VixVM_Open.argtypes = [VixHandle,c_char_p,POINTER(VixEventProc),c_void_p]

In 2.5 this code is correctly, but in 3.2 it returns ctypes.ArgumentError

What can I do?? thanks

+5  A: 

Your second argument has to be encoded to a format that the VIX API will understand, since Python 3.x now creates all strings as Unicode. The simplest approach would be to modify your second argument to read:

"C:\\MyVirtualMachine.vmx".encode('ascii','ignore')

which should give you a variable of type bytes, which should be more palatable to VIX.

Paul McGuire
Making this the problem was soluted!! thank you very much!! where can I vote you???
igferne