Thanks Thomas, it works. 

Serge Weinstock

-----Original Message-----
From: Thomas Heller [mailto:thel...@ctypes.org] 
Sent: 26 November 2009 12:04
To: comtypes-users@lists.sourceforge.net
Subject: Re: [comtypes-users] SafeArray of pointers to variant

serge.weinst...@barclayscapital.com schrieb:
> Hi Thomas,
> 
> Looking at the MSDN documentation for SafeArrayCreate 
> (http://msdn.microsoft.com/en-us/library/ms893380.aspx), I've found
> that: "Neither VT_ARRAY nor the VT_BYREF flag can be set" whatever the

> referenced type.

Yes, but the docs for SafeArrayCreateEx or SafeArrayCreateVectorEx do
NOT have such a notice.  Whatever that means.

> After discussion, I've found that it's a mistake in the IDL, it should

> have been "SAFEARRAY(VARIANT)" and not "SAFEARRAY(VARIANT*)".
> 
> Unfortunatly, I can't change the existing code. 

> In fact, I don't need to use this particular object but I need to use 
> other objects defined in the same type library. The problem is that 
> when I try to import the type library with 
> "comtypes.client.GetModule", an exception is thrown when processing
this particular method.
> 
> Is there a way to get around it? Maybe by interpreting 
> "SAFEARRAY(VARIANT*)" as "SAFEARRAY(VARIANT)"?

An easy fix is to insert this line
  POINTER(VARIANT): VT_BYREF|VT_VARIANT, into the definition of the
_ctype_to_vartype dictionary, at the end of the comtypes\automation.py
module.

This will let you import the typelib, but you will get an error if you
want to call a method that uses such an argument type.

Thomas

------------------------------------------------------------------------
------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008
30-Day trial. Simplify your report design, integration and deployment -
and focus on what you do best, core application coding. Discover what's
new with Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users
_______________________________________________

This e-mail may contain information that is confidential, privileged or 
otherwise protected from disclosure. If you are not an intended recipient of 
this e-mail, do not duplicate or redistribute it by any means. Please delete it 
and any attachments and notify the sender that you have received it in error. 
Unless specifically indicated, this e-mail is not an offer to buy or sell or a 
solicitation to buy or sell any securities, investment products or other 
financial product or service, an official confirmation of any transaction, or 
an official statement of Barclays. Any views or opinions presented are solely 
those of the author and do not necessarily represent those of Barclays. This 
e-mail is subject to terms available at the following link: 
www.barcap.com/emaildisclaimer. By messaging with Barclays you consent to the 
foregoing.  Barclays Capital is the investment banking division of Barclays 
Bank PLC, a company registered in England (number 1026167) with its registered 
office at 1 Churchill Place, London, E14 5HP.  This email may relate to or be 
sent from other members of the Barclays Group.
_______________________________________________

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users

Reply via email to