Am 12.02.2010 20:24, schrieb Pablo Bianucci: > Hi Thomas! > > On Fri, 12 Feb 2010, Pablo Bianucci wrote: > >> Exception: Cannot put <cparam 'P' (012D7468)> in VARIANT > > The problem seems to be that the initialization of VARIANT does not know > what to do with a pointer type. I think that VARIANT could be extended to > handle those: > > Get the value of the pointer (no the contents but the actual address), > store that as the content of the VARIANT instance and then set the > VT_BYREF flag. Do you think that would work?
Exactly. I cannot provide a patch, but here's a code snippet that creates such a beast: from comtypes.automation import * mode = c_int(42) # our variable v = VARIANT() v._.c_void_p = cast(pointer(mode), c_void_p) v.vt = VT_BYREF | VT_I4 print v # prints 'VARIANT(vt=0x4003, byref(42))' You could use this stuff and pass it to Invoke. I assume that is will be changed after the call. Pretty straightforward to retrieve the result; VARIANT contains code for that. Since the VARIANT is a kind of pointer, I have chosen the indexing to acces the contained value: print v # prints 'VARIANT(vt=0x4003, byref(42))' print v[0] # prints '42' > What I don't see how to do is how to get the address pointed to as a plain > number. cast does that for you, without worring about the actual address. -- Thanks, Thomas ------------------------------------------------------------------------------ SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev _______________________________________________ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users