ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> ctypes-users
ctypes-users
[ctypes-users] Getting value out of a VARIANT array
by Sumeet Sobti other posts by this author
Feb 10 2006 1:01PM messages near this date
[ctypes-users] Question from ebay member | [ctypes-users] 1
Hi,

I am using ctypes.com to access a COM object. The
object has a method whose return type is VARIANT. The
method is described in the readtlb-generated code as:

STDMETHOD(HRESULT, "_get_Get", VARIANT,
POINTER(VARIANT)),

I am using code like the following to invoke the
method:


from ctypes.com.automation import VARIANT
from ctypes import byref

input_variant = VARIANT('last')
output_variant = VARIANT()

obj._get_Get(input_variant, byref(output_variant))


Then I try to get the value out through
output_variant.value.

The above code works fine when the method returns a
simple variant containing a single string.

(1) The code does *not* work when the method returns a
variant that is an array of variants. In that case, I
get this error:

> >> output_variant.value
Traceback (most recent call last):
  File "<stdin> ", line 1, in ?
  File
"c:\Python24\lib\site-packages\ctypes\com\automation.py",
line 495, in _get_value
    data = TYPECODE[self.vt & ~VT_ARRAY]()
KeyError: 12

(2) The code also does *not* work when the method
returns a two dimensional array.

It fails with this error:

> >> output_variant.value
Traceback (most recent call last):
  File "<stdin> ", line 1, in ?
  File
"c:\Python24\lib\site-packages\ctypes\com\automation.py",
line 490, in _get_value
    assert dim == 1
AssertionError

------

How can I get the value out of a VARIANT when it
contains an array of variants or a 2-dimensional
array. 

Thanks!

-Sumeet.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
ctypes-users mailing list
ctypes-users@[...].net
https://lists.sourceforge.net/lists/listinfo/ctypes-users

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved