Re: [comtypes-users] Problem calling method [SEC=PERSONAL]
Hi Andrew! On Wed, 17 Feb 2010, Andrew MacIntyre wrote: piezo1.GetMaxTravel(APTPiezoLib.CHAN1_ID, pointer(tr)) I'm curious as to any reasons to prefer the above instead of piezo1.GetMaxTravel(APTPiezoLib.CHAN1_ID, byref(tr)) You can chalk it up to my mind working more in C Mode that Visual Basic Mode, I guess. :-) Both seem to work and the first one is the one that popped up initially in my mind. Bye Good Luck! Pablo B. -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users
Re: [comtypes-users] Problem calling method
Hi Thomas! On Mon, 15 Feb 2010, Thomas Heller wrote: Here is a patch for comtypes that will pass byref(...) or pointer(...) arguments as VT_BYREF variants. It should workfor Pablos and Michaels use cases - also it demonstrates how to access the original object of a byref(..) call: Yup, it works! Now it is as easy (and intuitive, I'd say) as this: === tr = c_float() piezo1.GetMaxTravel(APTPiezoLib.CHAN1_ID, pointer(tr)) === Great! Thanks again! Bye Good Luck! Pablo B. -- 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
Re: [comtypes-users] Problem calling method
Hi Thomas! On Fri, 12 Feb 2010, Thomas Heller wrote: Exactly. I cannot provide a patch, but here's a code snippet that creates such a beast: Yes! It works!! This is the final working snippet: snip travel = c_float(0) v = VARIANT() v._.c_void_p = cast(pointer(travel), c_void_p) v.vt = VT_BYREF | VT_R4 mode = c_int(0) vm = VARIANT() vm._.c_void_p = cast(pointer(mode), c_void_p) vm.vt = VT_BYREF | VT_I4 try: piezo1.GetMaxTravel(APTPiezoLib.CHAN1_ID, v) piezo1.GetControlMode(APTPiezoLib.CHAN1_ID, vm) except Exception, e: print Exception:, e print travel.value, mode.value /snip If you are not careful when setting the types you get a Type Mismatch error (even though the protoypes in the help were the same, I had to use different types for the two funcions there). I wonder why you can't integrate this into the package. I'm fine as this, as this will let me write the program I need, but it would be more user friendly to be able use pointers as arguments for the method invocation. But I don't understand COM internals, so it could be that implementing that could lead to other problems. Thank you very much for your help! Bye Good Luck! Pablo. P.S.: If you visit Canada and stay at a city I happen to be living in, consider yourself invited to a drink. ;-) -- 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