win32: using postdata and safearray

mic aldo123 at onet.pl
Tue Mar 16 07:11:42 EST 2004


I'm stuck with following problem. Using webbrowser control I try to make
custom-made request. I found working example of this written in VBS but
porting it to Python doesn't seem to work. The key is navigate (or
navigate2) method, that accepts PostData as one of it's parameters.
As stated in reference:
"The post data specified by PostData is passed as a SAFEARRAY Data Type
structure. The variant should be of type Array and point to a SAFEARRAY Data
Type. The SAFEARRAY Data Type should be of element type Integer, dimension
one, and have an element count equal to the number of bytes of post data."

Therefore I try to send simple 'ABC' string together with HTTP request by
creating list of ascii integers [65,66,67]. The list is supposed (as far as
I understand) to be automatically converted into safearray, but instead of:
[hex]: 41 42 43

the sequence of following bytes is being sent:
[hex]: 03 00 34 00 00 00 00 00 41 00 00 00 00 00 00 00 03 00 34 00 00 00 00
00 42 00 00 00 00 00 00 00 03 00 34 00 00 00 00 00 43 00 00 00 00 00 00 00
a3 f0 00

What's curious, I noticed some small differences between using tuples and
lists - the tuple seem to add some additional bytes at the end. It looks
like some wrong conversion of types, but I don't know any idea how to fix it
or maybe convert it manually.

Regards,

Michal





More information about the Python-list mailing list