Python Windll - passing python lists to DLL function using Windll
Robin Becker
robin at jessikat.fsnet.co.uk
Thu Aug 1 06:48:09 EDT 2002
In article <ad5b37b7.0207311413.7a1bfd4 at posting.google.com>, SK
<skunix at hotmail.com> writes
>Hello,
>
>I have a function named TestMap() with the following prototype:-
>
>void TestOpenCluster(_InputParamMap MapStateBefore);
>
>where,
> typedef std::map<char**,char**> _InputParamMap ;
>
>How do I pass the python list to this function using Windll? I got an
>AV with the following code?
>
>import windll
>arr =[ (windll.cstring('VAR1'),windll.cstring('VALUE1')),
> (windll.cstring('VAR2') , windll.cstring('VALUE2'))
> ]
>modl = windll.module('MyTestDll')
>modl.TestMap(arr)
>Exception exceptions.AttributeError: "cstring instance has no
>attribute 'mb'" in ignored
>Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "C:\Python22\windll.py", line 44, in __call__
> args
>TypeError: an integer is required
>
>
>Thanks in Advance.
>/SK
I think you need to use structob.struct_object + oracle.Oracle or
windll.membuf to create the required arrays somehow.
I'm fairly sure that windll doesn't handle converting lists/tuples
itself.
With windll.membuf your length two char** things are 2*4 bytes long
so I guess uncertainly
A0 = windll.membuf(8)
A0[0] = int(windll.cstring('VAR1'))
A0[4] = int(windll.cstring('VALUE1'))
A1 = windll.membuf(8)
A1[0] = int(windll.cstring('VAR2'))
A1[4] = int(windll.cstring('VALUE2'))
modl = windll.module('MyTestDll')
modl.TestMap(A0,A1)
let's hear if that's right/wrong?
--
Robin Becker
More information about the Python-list
mailing list