[python-win32] using InvokeTypes?
mhammond at skippinet.com.au
Sat Dec 3 07:11:28 CET 2005
> There Mark Hammond writes:
> "Sadly there is no easy way to explicitly specify the exact variant
> type, other than using InvokeTypes. "
> So now I would like to throw an eye at InvokeTypes, been searching a
> bit, but only found non-commented InvokeTypes. How do I find the
> values of input/output lists, flags and so on.
I'm afraid it is poorly documented, as you have discovered.
InvokeTypes is very similar to the Invoke method, which is very similar to
the IDispatch Invoke method. The primary documentation for that can be
found at MSDN.
There are 2 args that do need special documentation though: resultTypeDesc
and typeDesc. resultTypeDesc describes the return value of the function,
and is a tuple of (type_id, flags). typeDesc describes the type of each
parameters, and is a list of the same (type_id, flags) tuple.
type_id is a valid "variant type" constant (eg, VT_I4 | VT_ARRAY, VT_DATE,
etc - see VARIANT at MSDN). flags is one of the PARAMFLAG constants (eg,
PARAMFLAG_FIN, PARAMFLAG_FOUT, etc - see PARAMFLAG at MSDN).
Eg, an example from the makepy generated file for Word:
def SetWidth(self, ColumnWidth=..., RulerStyle=...):
return self._oleobj_.InvokeTypes(202, LCID, 1, (24, 0), ((4, 1), (3,
The interesting bits are:
resultTypeDesc: (24, 0) - (VT_VOID, <no flags>)
typeDesc: ((4, 1), (3, 1)) - ((VT_R4, PARAMFLAG_FIN), (VT_I4,
So, in this example, the function returns no value, and takes 2 "in"
params - ColumnWidth is a float, and RulerStule is a short int.
Hope this helps (I've also added something based on the above to the
More information about the Python-win32