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.

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)"?
 
Thanks,
Serge Weinstock

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

serge.weinst...@barclayscapital.com schrieb:
> Hi,
>  
> I'm trying to import a COM type library with the statement 
> "comtypes.client.GetModule(("{09022755-93B0-4BA8-9593-AC74E4C6EABB}", 
> 1, 0))"
>  
> The module is correctly generated but when imported, I got an 
> exception
> on:
>  
> class
> NamedCommandSession(comtypes.gen._00020430_0000_0000_C000_000000000046
> _0
> _2_0.IUnknown):
>     _case_insensitive_ = True
>     u'Named command session interface.'
>     _iid_ = GUID('{44D908E9-7600-4C9D-ADE7-917D59EEA175}')
>     _idlflags_ = ['oleautomation']
> NamedCommandSession._methods_ = [
>     COMMETHOD([], HRESULT, 'Execute',
>               ( ['in'], BSTR, 'commandName' ),
>               ( ['in'], _midlSAFEARRAY(BSTR), 'paramNames' ),
>               ( ['in'], _midlSAFEARRAY(POINTER(VARIANT)),
'paramValues'
> ),
>               ( ['retval', 'out'], POINTER(BSTR), 'ppResult' )), ]
> 
> The method "midlSAFEARRAY" doesn't handle the safearray with elements 
> of type POINTER(VARIANT).
> 
> Is there a quick fix for that?

I hacked around a little, but failed to create such a safearray.
I assume the typecode is VT_BYREF|VT_VARIANT, but calling
SafeArrayCreateVectorEx(VT_BYREF|VT_VARIANT, 0, 42, NULL) returns zero
(= failure).  Do you have some C-example code?

--
Thanks,
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