COM method with pointer args

Alex Martelli aleaxit at yahoo.com
Mon Jun 18 10:37:27 CEST 2001


"Levente Sandor" <sandorlevi at yahoo.com> wrote in message
news:8b5e42a6.0106171630.43a3303a at posting.google.com...
> I need to automate some jobs in CorelDRAW, and there are a lot of methods
which
> returns their results through pointers.
> Is there a possibility to use a COM method which requires pointer
arguments?
> (From Python, of course :)

Sure, as long as you have a type library that is correct.  Make
sure your Python client IS using the type library, e.g. by using
    win32all.client.gencache.EnsureDispatch(...)
rather than
    win32all.client.Dispatch(...)

Once the type-library IS thus being used, all [out] parameters
of methods will disappear from the parameter-list and become
extra items in a returned tuple, instead.  [in,out] parameters
will be BOTH in the parameter-list (for the [in] part only)
AND extra items in the returned tuple (for the [out] part).

You can read the Python source that is generated (in the
gen_py subdirectory of D:\Python21\win32com, or wherever
you installed) in subdirectories whose names are the GUID's
for the type-libraries you have "gencached".  (You can
also choose to use makepy and build the wrapper for a
whole typelibrary into one .py file, but the "on-demand"
approach that EnsureDispatch uses by default is superior,
IMHO -- YMMV).


Alex






More information about the Python-list mailing list