Mustafa, are you still interested in a solution?

If so, can you get the most recent source code from this SVN branch
(please make sure you clear the comtypes\gen directory after that)

http://svn.python.org/projects/ctypes/branches/comtypes-0.4/

I changed the way [in, out] parameters are handled with comtypes;
it should be possible now for you to call the method without any parameter:

>>> myrefs = Send.GetListOfDependantFiles()

Thanks,
Thomas

Mustafa Görmezer schrieb:
> Hi Thomas,
> 
> that wasn`t it. Your example returns me a list of 500 Nones. It`s right,
> the method expects a list or a tuple. But it does not matter what is in
> the list. It returns me everything.
> 
> Hint: The number 500 was to initialize the BSTR array with a size of
> 500. Do I need it in Python ?!
> 
> The problem is the same with win32com, here:
> https://sourceforge.net/tracker/?func=detail&atid=551954&aid=1920299&group_id=78018
> 
> Any other ideas ?
> 
> best regards
> 
> Mustafa Görmezer
> 
> 
> Thomas Heller schrieb:
>> Mustafa Görmezer schrieb:
>>> Hello,
>>>
>>> I am automating a CAD System which expects a so called 
>>> CATSafeArrayVariant. This is defined as one-dimensional arrays of 
>>> CATVariants. When I am right, this should work now with comtypes. But 
>>> how do I use it when a method expects it by reference ?
>>>
>>> In pure Python (where no "by reference" exists) I would simply use this 
>>> to get a list of file names:
>>>
>>> myrefs = Send.GetListOfDependantFiles()
>>>
>>> In VB (which works) it looks like:
>>>
>>> Dim arrayOfVariantOfBSTR()
>>> ReDim arrayOfVariantOfBSTR(500)
>>> Call Send.GetListOfDependantFiles(arrayOfVariantOfBSTR)
>>>
>>> After this I can find the results in the arrayOfVariantOfBSTR, which can 
>>> be used in a for each loop.
>> 
>> I looked into the generated file that you sent me offline.  The 
>> GetListOfDependantFiles()
>> method uses an [in, out] parameter, apparently a SAFEARRAY of BSTR (an array 
>> of strings).
>> 
>> You must call the method with a list (or tuple) containing strings, comtypes 
>> will
>> pack these automatically into a safearray, the com object will insert its 
>> results
>> into the safearray, and comtypes will unpack it again and return a them as a 
>> sequence.
>> 
>> So I assume that something like this *should* work:
>> 
>> result = send.GetListOfDependantFiles([None] * 500)
>> for item in result:
>>     print item
>> 
>> Thomas

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users

Reply via email to